Non-blocking socket errors

H

Heiko Wundram

Hi all!

Does anybody know whether there is some form of concise reference to what
behaviour sockets (AF_INET,SOCK_STREAM) exhibit when the remote end closes
the writing/reading channel? I've looked at the sources of different
implementations of event-loops (asyncore, medusa, twisted), and each of them
seems to handle a different set of errors as representative for premature
closing of one direction of the socket.

Let me give a little example of what I have found out (and this seems to be
similarily handled in asyncore, medusa and twisted):

Client -> shutdown(1)
Server -> socket is readable and recv() returns ""
-> signal server code that shutdown on read has happened.

But what happens if the following occurs:

Client -> shutdown(0)
Server -> ?? Nothing special happens, further writes succeed, until the OS
send-buffer is full, and never raise an error.

Of course, you can create a myriad of combinations with this.

What's especially interesting for me is the case that the client calls
shutdown(0), but the server still has data to be transmitted, and should thus
signal to itself that the data has not been transferred completely.

Anyway, is there some form of reference to the behaviour of sockets? man 2
recv/send aren't especially helpful in this respect, and what else I've found
on the web for socket-programming isn't either... I know that each OS shows
different behaviour, but I'm actually just interested in the Linux 2.x
IP-stack with glibc.

Heiko.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,787
Messages
2,569,630
Members
45,338
Latest member
41Pearline46

Latest Threads

Top