This page is a discussion on the mentioned topic. Most of the answers are in their original posted form, including any technical/spelling/grammatical errors. No guarantees are expressed or implied. :-)
Comments, corrections, concerns about this tip?
I use a program that perform a loop reading from a socket connection, until
the connection is dropped by the remote system. Unfortunately, sometimes the
remote system does not drop the connection so my program waits forever.
I tried the fcntl() function with the O_NONBLOCK flag, to test data
existence prior to read, but I get always the message "invalid parameter
value" in issuinf fcntl();
Any solutions?
Answer(s):
Use the select() function (before each read/write to a socket)... it allows
you to specify any time-out value you want.