in reply to Re^2: Handling sockets in a server
in thread Handling sockets in a server
close on a socket could fail if the file descriptor has already been reaped [EBADF]. [EINTR] is also possible.
close is different from shutdown because close only cleans up the file descriptor in the current process, but shutdown will terminate the connection for all processes using it.
That is to say, if you fork a child process that has an open socket, closing it within either process will free the file descriptor associated with that socket, within that process, but the other process will be free to continue using it's copy of the file descriptor and the socket.
However, shutdown will terminate the connection for all processes that have a file descriptor associated with it. The file descriptor will remain after shutdown until they are explicitly closed or otherwise GC'd.
Not having a real fork available, I'll leave questions 3 & 4 to others :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Handling sockets in a server
by skerr1 (Sexton) on Oct 21, 2005 at 18:23 UTC | |
by BrowserUk (Patriarch) on Oct 21, 2005 at 19:14 UTC | |
by skerr1 (Sexton) on Oct 23, 2005 at 03:07 UTC | |
by skerr1 (Sexton) on Oct 26, 2005 at 00:24 UTC | |
by skerr1 (Sexton) on Dec 01, 2005 at 04:10 UTC |