🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.os2.programmer.misc
Article #194

Sockets prog problems/questions; recv stays blocked when other end dies

#194
From: Keith Bennett
Date: Wed, 29 Mar 1995 00:00
46 lines
2705 bytes
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?)

Thanks for any help...
- Keith


-- 
--------------------------------------------------------------------------
Keith Bennett                             Bennett Business Solutions, Inc.
Silver Spring, MD USA                     OS/2 & DOS Software Development
kbennett@cpcug.org                        (301) 871-7696
Technical Details
Message-ID: <3lc25d$kt1@cpcug.org>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 106983,d2ec22b1757b70e6,start
X-Google-Attributes: gid106983,public
X-Google-Thread: 10cd94,d2ec22b1757b70e6,start
X-Google-Attributes: gid10cd94,public
X-Google-Thread: 11307a,d2ec22b1757b70e6,start
X-Google-Attributes: gid11307a,public
From: kbennett@cpcug.org (Keith Bennett)
Subject: Sockets prog problems/questions; recv stays blocked when other end dies
Date: 1995/03/29
Message-ID: <3lc25d$kt1@cpcug.org>
X-Deja-AN: 100531502
organization: Express Access Online Communications USA: 800-969-9090
newsgroups: comp.os.os2.programmer.misc,comp.os.os2.networking.tcp-ip,bit.listserv.os2-l