home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / next / programm / 5669 < prev    next >
Encoding:
Text File  |  1992-08-17  |  2.8 KB  |  61 lines

  1. Newsgroups: comp.sys.next.programmer
  2. Path: sparky!uunet!usc!sdd.hp.com!elroy.jpl.nasa.gov!ames!agate!boulder!alumni.cs.colorado.edu!rademach
  3. From: rademach@alumni.cs.colorado.edu (SIMON RADEMACHER)
  4. Subject: select() broken?
  5. Message-ID: <1992Aug18.042006.12768@colorado.edu>
  6. Summary: does select() break after a disconnect?
  7. Sender: news@colorado.edu (The Daily Planet)
  8. Nntp-Posting-Host: alumni.cs.colorado.edu
  9. Organization: University of Colorado, Boulder
  10. Date: Tue, 18 Aug 1992 04:20:06 GMT
  11. Lines: 48
  12.  
  13.  
  14. Hopefully, this should be easy, but perhaps a bit dull--no graphics
  15. nor even Objective C here.
  16.  
  17. We've developing a suite of programs here that use tcp sockets for
  18. communications.  Select() is used to multiplex communications.  Everything
  19. goes ok until one program disconnects from another. Then, select() in the
  20. second program never detects any furthur events on any file descriptors,
  21. including ones that it was detecting events on before the disconnect.
  22. So, does select() have a bug?
  23.  
  24. Here's a more complete description of what happens with one of the programs:
  25. 1) The program opens three tcp socket services and one client. The client
  26.    successfully connects.
  27. 2) It then does a select() in the main loop.  It uses a timeout in the
  28.    select() so that it can do other, clock-based work.  The timeout has
  29.    ranged from 100 microseconds to over 1 second with the same results.
  30. 3) The select() correctly identifies connection requests on the services
  31.    as well as data arriving on the client.  When a connect request is
  32.    seen, an accept() is done, and the new fd is added to the read fd_set.
  33. 4) Data arriving on the newly accepted fd is noted and read.
  34. 5) When one of the accepted fd's disconnects, the read fd_set shows an
  35.    event on the fd.  A read is done resulting in EOF.  The fd is closed()
  36.    and removed from the read fd_set.
  37. 6) From then on, the select() always waits for the duration of the time-
  38.    out, and returns 0, eg. no events in any of the sets.
  39.  
  40. Note, the following possible causes have been checked.
  41. a) The read fd_set IS rebuilt before each select() call.  The except fd_set
  42.    is also built and is the same set as the read.  The write fd_set is set
  43.    to NULL 'cause I don't care about writes.  Although the except is sent to
  44.    select(), any exceptions are currently ignored.  (Shouldn't be a problem,
  45.    right?)
  46. b) The number of fds select() should look at (nfds) is larger than the
  47.    greatest fd number.
  48. c) The socket fd given from socket() is not closed, just the fd given by
  49.    the accept call.
  50.  
  51. Another program behaves similarly, but includes stdin in the read fd_set
  52. for user input.  When it looses its client connection, it also ignores
  53. input on other inputs, including stdin.
  54.  
  55. Any clues?  Oh, BTW, this occures on 2.1 and 3.0PR2.
  56. Thanks in advance for any help.
  57. -- 
  58. Simon Rademacher
  59. rademach@alumni.cs.colorado.edu
  60.  
  61.