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