Article View: comp.os.os2.programmer.misc
Article #196Re: Sockets prog problems/questions; recv stays blocked when other end dies
From: Clayton O'Neill
Date: Wed, 29 Mar 1995 00:00
Date: Wed, 29 Mar 1995 00:00
48 lines
3010 bytes
3010 bytes
Keith Bennett (kbennett@cpcug.org) wrote: : The following questions pertain to programming sockets using : IBM's TCP/IP for OS/2 version 2.0 (UN 64092). Our app is : running under OS/2 2.1 (not 2.11) and we hope to eventually : upgrade to Warp. : We have found that when doing a blocking read (recv()) on a : socket, the read will not return if the machine on the other end : of the socket has been switched off or rebooted. (Despite our : warnings, our customers do it from time to time and we have : decided to accommodate for that somehow in our software.) : 1) Is this behavior correct according to the TCP/IP standard (or : convention if there isn't a standard)? : 2) Is there a way to get the recv() to detect the shutdown and : return an error code? : 3) Are there any other situations that would cause the recv() to : block incorrectly? (When planning our defense against this : situation we would like to know all of the possible causes up : front.) : 4) What would you recommend as the best way to detect the demise : of the other end? We've been thinking of having a separate : thread pinging all remote hosts that have sockets connected, and : forcibly closing any sockets connected to a machine that has : died. That gets elaborate though, as we'd have to keep track of : which sockets are connected to whom, etc. : A slightly different solution would still have a separate thread : checking the other machines, but instead of pinging have a : separate special purpose socket with periodic keepalive : messages. It is our understanding that sockets are more : reliable than ping (tcp vs. udp) and that sending messages : across an open socket would require less overhead than ping. : (Is that correct?) I seem to remember the toolkit letting you set the TCP keepalive timeout through the setsockopt function. Also, I believe thtat in IAK there is something to set keepalive for the entire system. This might help your problem. -- ------------------------------------------------------------------------- coneil@tiger.lsu.edu - <Insert some witty saying here> oneill@bit.csc.lsu.edu - http://bit.csc.lsu.edu/~oneill/
Technical Details
Message-ID:
<3lcgsc$2hj1@tiger1.ocs.lsu.edu>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<3lc25d$kt1@cpcug.org>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cd94,d2ec22b1757b70e6 X-Google-Attributes: gid10cd94,public X-Google-Thread: 11307a,d2ec22b1757b70e6 X-Google-Attributes: gid11307a,public X-Google-Thread: 106983,d2ec22b1757b70e6 X-Google-Attributes: gid106983,public From: coneil@tiger.lsu.edu (Clayton O'Neill) Subject: Re: Sockets prog problems/questions; recv stays blocked when other end dies Date: 1995/03/29 Message-ID: <3lcgsc$2hj1@tiger1.ocs.lsu.edu> X-Deja-AN: 100531521 references: <3lc25d$kt1@cpcug.org> followup-to: comp.os.os2.programmer.misc,comp.os.os2.networking.tcp-ip,bit.listserv.os2-l organization: Louisiana State University newsgroups: comp.os.os2.programmer.misc,comp.os.os2.networking.tcp-ip,bit.listserv.os2-l