Enabling O_NONBLOCKING in C on LINUX
*** background **** I am new to TCP, so I have a question that might be a little basic. I am trying to enable O_NONBLOCK on a socket that is receiving data. So far I've tried to set O_NONBLOCK, itcl () and fcntl () differently. I am currently trying to get fcntl () to work.
My question is: should you set O_NONBLOCK before or after socket connection?
** my current implementation of fcntl () is based on disabling the link before code:
How do I reset the socket back to blocking mode (after I set it to non-blocking mode)?
//set socket to NONBlocking
on = fcntl(Socket,F_GETFL);
on = (on | O_NONBLOCK);
if(fcntl(Socket,F_SETFL,on) < 0)
{
perror("turning NONBLOCKING on failed\n");
}
// DO CONNECT
rc = connect()
Thanks for taking the time to look at this.
+3
source to share