home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / unix / question / 15479 < prev    next >
Encoding:
Text File  |  1993-01-12  |  1.2 KB  |  37 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!elroy.jpl.nasa.gov!usc!howland.reston.ans.net!sol.ctr.columbia.edu!The-Star.honeywell.com!umn.edu!csus.edu!netcom.com!bilan
  3. From: bilan@netcom.com (Steve Bilan)
  4. Subject: Re: Sockets: How do I detect when it has unexpectedly closed
  5. Message-ID: <1993Jan12.234227.29729@netcom.com>
  6. Organization: Netcom
  7. References: <1993Jan11.200716.14442@bvl.pt> <1993Jan12.114400.3620@bvl.pt>
  8. Date: Tue, 12 Jan 1993 23:42:27 GMT
  9. Lines: 26
  10.  
  11. vasco@bvl.pt (antonio vasconcelos) writes:
  12. >ejohnson@void.ncsa.uiuc.edu (Eric E. Johnson) writes:
  13. >: I know how to close a connection.  That's easy.  My question is: how do
  14. >: I detect that a socket (AF_INET, SOCK_STREAM) has been unexpectedly 
  15. >: disconnected from its remote client?  I'm assuming a case where the
  16. >: remote client has crashed and was unable to send out a "closing"
  17. >: message.
  18. >
  19. >then, in the main() you just have to setup signal handlers.
  20. >
  21. >    signal(SIGINT,byebye);
  22. >    signal(SIGPIPE,snifserver);
  23. >
  24. >By the way, if the client dies, the server should recive a SIGPIPE too.
  25.  
  26.  
  27. That works fine for an app with one socket, but if you have an
  28. app with two (or more) sockets open, how can you detect an abnormal
  29. socket close and know which socket it's on?
  30.  
  31.  
  32.  
  33.  
  34. M, BATR..
  35. ..Steve Bilan
  36.  
  37.