home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / unix / wizards / 5666 < prev    next >
Encoding:
Internet Message Format  |  1993-01-28  |  1.6 KB

  1. Path: sparky!uunet!opl.com!hri.com!spool.mu.edu!uwm.edu!ux1.cso.uiuc.edu!news.cso.uiuc.edu!void!ejohnson
  2. From: ejohnson@void.ncsa.uiuc.edu (Eric E. Johnson)
  3. Newsgroups: comp.unix.wizards
  4. Subject: Re: Detection broken tcp connection
  5. Keywords: tcp connection broken
  6. Message-ID: <ejohnson.728168994@void>
  7. Date: 27 Jan 93 21:09:54 GMT
  8. References: <wv.728144099@bambam>
  9. Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
  10. Organization: University of Illinois at Urbana
  11. Lines: 31
  12.  
  13. wv@dasc.nl (Wouter Visscher) writes:
  14.  
  15. >The manuals are not to clear on this subject, testing showed  the above calls
  16. >i.e. select, send, recv did not return error codes indicating a problem.
  17. >Mind you if an error code is only return once I might have missed it during
  18. >this test
  19.  
  20. Lucky you.  I just learned the answer to this question last week.
  21.  
  22. If your sockets are...
  23.  
  24. Blocking... then just wait for a read to return zero bytes, indicating a
  25. broken connection.  I don't use blocking sockets, so I have no
  26. experience with this method.
  27.  
  28. NonBlocking... Watch for select() to claim that one of the sockets can
  29. be read from by setting the appropriate descriptor bit.  Then, when you
  30. go to read the socket via a non blocking read, you will get zero bytes
  31. back when the socket connection is broken.  Keep in mind that normally,
  32. a zero means, "No new data".  It only means "Broken connection" when
  33. select() indicates that the socket should be read from.
  34.  
  35. This should do the trick.
  36.  
  37. Eric
  38.  
  39.  
  40.  
  41. -- 
  42. Eric E Johnson             | "Sigsoft is a black hole of ambition, everything
  43. ejohnson@a.cs.uiuc.edu     |  gets sucked in, and nothing comes out." - Me
  44.