Non-Blocking Sockets in Linux
Hello all, How do you set a socket to non-blocking/blocking status in linux? In win32 I used ioctlsocket(...), what is the linux equivalent of this? Thank You!
fcntl(socket,F_SETFL,O_NONBLOCK);
Are you sure that you wish to use non-blocking I/O though?
I'm of the opinion that it's generally better to create a new thread for doing concurrent I/O and use blocking I/O operations.
Are you sure that you wish to use non-blocking I/O though?
I'm of the opinion that it's generally better to create a new thread for doing concurrent I/O and use blocking I/O operations.
Threading brings with it all the synchronisation issues however, not to mention isn't as scalable. The latter may not often be a problem but the former may be.
The HTTP GET sample runs on Windows and Linux, and uses non-blocking sockets. It contains a header (sock_port.h) which makes socket programming more portable.
The specific strategy used on Linux is to not change the socket, but instead pass the MSG_DONTWAIT flag. Anyway, if you're doing Linux and Windows programming, you might want to look at that sample.
The specific strategy used on Linux is to not change the socket, but instead pass the MSG_DONTWAIT flag. Anyway, if you're doing Linux and Windows programming, you might want to look at that sample.
enum Bool { True, False, FileNotFound };
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement