An irritating limitation of listening socketsTraditional sockets implementations have an irritating limitation, at
least for TCP sockets: it is impossible to gracefully and cleanly shut
down listening (server) sockets.
The problem is that kernels accept new TCP connections for listening
sockets without asking your server; This means that to shut down cleanly,
you need a two-stage process: first you tell the kernel to stop accepting
new connections for you, and then you process all of the existing
accepted connections. If you simply dump everything, clients will see
abrupt disconnections of established connections, because from their
perspective the connection is complete; their Unfortunately, there's no two-stage close interface for server sockets (at least, none that I can see):
(You can do this with Unix domain sockets, by removing the socket file itself without closing your server socket fd.) Among other consequences, this means that protocols where the client connections and immediately starts sending data are dangerous; the client had better be prepared for the entire conversation to fail. The only way to make sure that the server is really there (instead of in the process of shutting down) is to wait for it to send you something, which may be why so many Internet protocols start with greeting banners from the server. (As a pragmatic matter the server can lower the risk by not closing
things down until (One comment.)
|
These are my WanderingThoughts GettingAround This is part of CSpace, and is written by ChrisSiebenmann. * * * Atom feeds are available; see the bottom of most pages. Categories: links, linux, programming, python, snark, solaris, spam, sysadmin, tech, unix, web |