fcntl() + Blocking

Apr 15, 2009 at 11:21pm
Hi Guys,

I have a quick question, I have set up a socket file descriptor to non-blocking mode using fcntl() function call. Now how do I set this back to blocking mode?

Thanks a lot in advance

Apr 16, 2009 at 12:45am
Surprisingly simple:

1
2
int flags = fcntl(fd, F_GETFL);
int result = fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);

Apr 16, 2009 at 1:06am
You are awesome. Thanks a lot dude.
Apr 16, 2009 at 3:50am
Just wait until you learn the wonders of poll(2).

:-)
Topic archived. No new replies allowed.