I implement bridge by taking packets from nfqeueue , open socket to the eth card and send the packets (i have some logic in the middle).
i am new to cpp and low level , so i might ask stupid questions.
if i understand correct i shouldn't open-close the socket for every packet. i write my code based on this example - http://austinmarton.wordpress.com/2011/09/14/sending-raw-ethernet-packets-from-a-specific-interface-in-c-on-linux/
i open socket like this:
sockfd = socket(AF_PACKET, SOCK_RAW, IPPROTO_RAW))
my question are: 1. for how long the socket alive? 2. how can i check if the socket i still open? 3. how do i close it? i saw the shutdown , but i didnt know if this is the API? 4. can someone direct me to an example in production level. means handling socket exception ...
Thank you