home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / os / os2 / networki / 2149 < prev    next >
Encoding:
Text File  |  1992-11-17  |  3.1 KB  |  66 lines

  1. Newsgroups: comp.os.os2.networking
  2. Path: sparky!uunet!ukma!wupost!zaphod.mps.ohio-state.edu!malgudi.oar.net!news.ans.net!ans.net!db3l
  3. From: db3l@ans.net (David Bolen)
  4. Subject: Re: close-on-exec/IBM tcpip dev.kit.
  5. Sender: news@ans.net (News Administrator)
  6. Message-ID: <1992Nov16.202453.18247@ans.net>
  7. In-Reply-To: yuk@hpopd.pwd.hp.com's message of Fri, 13 Nov 1992 10: 32:08 GMT
  8. Date: Mon, 16 Nov 1992 15:30:54 GMT
  9. References: <1992Nov10.082459.9024@kvamdata.no> <-159809996@hpopd.pwd.hp.com>
  10. Organization: Advanced Network & Services, Inc. - Elmsford, NY
  11. Lines: 53
  12.  
  13. In article <-159809996@hpopd.pwd.hp.com> yuk@hpopd.pwd.hp.com (Yuk Lun Chan) writes:
  14.  
  15. >>comp.os.os2.networking / db3l@ans.net (David Bolen) /  2:31 pm  Nov 11, 1992 /
  16. >>So it isn't like an extra copy of the socket is being made for the
  17. >>child.  No matter how many children your server starts, when the
  18. >>server decides to close a socket it is using, that socket will be
  19. >>completely closed.
  20. >
  21. >Is that means I can't passing a socket handle to a child, then close it
  22. >(the parent) and then open for another connection ? I am just thinking to
  23. >do that.
  24.  
  25. Yes, it means you can't do that.
  26.  
  27. However, what it also means is that you don't have to.  In other
  28. words, go ahead and pass the socket handle to your child process.
  29. Then just forget about it in the parent.  Let the child close the
  30. socket when it is done with it.  The parent can just go on and
  31. continue to create other sockets.
  32.  
  33. There are some interesting quirks in the global nature of sockets.
  34. One is that you have to be careful if you are handing sockets to
  35. processes that aren't you're children.  If you die, the process
  36. cleanup will close that socket since you originally created it.  With
  37. direct children, that's not a problem as they will die too - but if
  38. you handed that socket to a process that isn't your child, it will
  39. suddenly find it closed.
  40.  
  41. On the other hand - if you hand the socket to a child, who then
  42. proceeds to die without closing it, that socket will stay open until
  43. you exit or you close it (since you are the one that created it).  So
  44. in this case, if you will be running for a while, it's probably a
  45. smart idea to track your children, and try closing any sockets you
  46. gave them when they exit, just to be safe.
  47.  
  48. The global sockets have advantages and disadvantages.  It would
  49. probably have been nicer if they worked semantically just like file
  50. handles, but that wasn't possible in the first releases of IBM's
  51. TCP/IP (as its kernel was in user space).  I've often wondering how
  52. well it would work to handle sockets with an IFS driver though, so
  53. they were actually file handles.  The socket calls would create and
  54. access files in the \DEV\TCPIP tree or something (the IFS would be
  55. device IFS (\dev), rather than installing a new disk letter), and they
  56. would work just like file handles (ala Unix).
  57.  
  58. --
  59. -- David
  60. --
  61. /-----------------------------------------------------------------------\
  62.  \              David Bolen             \  Internet: db3l@ans.net      /
  63.   |   Advanced Network & Services, Inc.   \   Phone: (914) 789-5327   |
  64.  / 100 Clearbrook Road, Elmsford, NY 10523  \   Fax: (914) 789-5310    \
  65. \-----------------------------------------------------------------------/
  66.