Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I have written simple TCP server-client programs in 'C' on my RHEL 5 64 bit.
I want to add SEND and RECEIVE timeout for this socket; so that if server is not responding in given time, request will get timeout instead of waiting in "recv" call.
But I failed to do so. can anybody help around it OR can redirect me to some link that will explain this.
But this you tell about connect;
1) Is this applicable to "recv" and "send" system calls as well.
2) Is there any other way, other than signal handling; like we dose in case of normal sockets as follows,
yes that does make sense, I told you that alarm should work on send and recv functions.
There are three ways to place a timeout on an I/O operation involving a socket.
1. Call alarm, which generates the SIGALRM signal when the specified time has
expired. This involves signal handling, which can differ from one implementation
to the next, and it may interfere with other existing calls to alarm in the process.
2. Block waiting for I/O in select, which has a time limit built in, instead of blocking
in a call to read or write.
3. Use the newer SO_RCVTIMEO and SO_SNDTIME) socket options. The problem
with this approach is that not all implementations support these two socket options.
Each is appropriate, depending on the specific circumstances. I hope this helps.