Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.development.apps > #386
| From | Joe Pfeiffer <pfeiffer@cs.nmsu.edu> |
|---|---|
| Newsgroups | comp.os.linux.development.apps |
| Subject | Re: EOF, close(), shutdown(), on POSIX sockets |
| Date | 2012-01-12 12:57 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <1bfwfkr8w0.fsf@pfeifferfamily.net> (permalink) |
| References | <ylfk62gpn3hg.fsf@dd-b.net> <1br4zdh37t.fsf@pfeifferfamily.net> <jen0gi$bc0$1@odin.sdf-eu.org> |
Andrei Voropaev <avorop@mail.ru> writes: > On 2012-01-06, Joe Pfeiffer <pfeiffer@cs.nmsu.edu> wrote: >> >> I've never been able to get a clear understanding of exactly the >> conditions under which a receiver will get an EOF so it can know the >> other end has shut down. For my own applications (and protocols) I've >> taken to sending a distinguished character (a period '.' in many cases, >> appropriately enough) as the last output from a transmitter, so I can >> treat it as if it were an EOF and shut down the receiver appropriately. > > Strange. The conditions are perfectly clear. If your "recv" call returns > zero, then the other side won't send any more data. So that's EOF. You > may still try to send some data to the peer. But this shall fail with > EPIPE error if the peer has completely closed the socket. So, as long as > you are prepared to handle EPIPE, you are safe to send more data after > receiving EOF. > > Of course, many protocols allow sending of explicit notification to the peer > when more data is not going to be accepted. But even in this case you > should be ready to handle EPIPE error. You seem to be addressing the question of when the transmitter can know the receiver has shut down. My experience has been that when the *transmitter* has shut down, the receiver may wait an arbitrary amount of time in a read() before finally returning a 0.
Back to comp.os.linux.development.apps | Previous | Next — Previous in thread | Next in thread | Find similar
EOF, close(), shutdown(), on POSIX sockets David Dyer-Bennet <dd-b@dd-b.net> - 2012-01-05 17:17 -0600
Re: EOF, close(), shutdown(), on POSIX sockets Kaz Kylheku <kaz@kylheku.com> - 2012-01-06 01:10 +0000
Re: EOF, close(), shutdown(), on POSIX sockets David Dyer-Bennet <dd-b@dd-b.net> - 2012-01-06 09:59 -0600
Re: EOF, close(), shutdown(), on POSIX sockets Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2012-01-05 21:20 -0700
Re: EOF, close(), shutdown(), on POSIX sockets David Dyer-Bennet <dd-b@dd-b.net> - 2012-01-06 10:00 -0600
Re: EOF, close(), shutdown(), on POSIX sockets Andrei Voropaev <avorop@mail.ru> - 2012-01-12 16:07 +0000
Re: EOF, close(), shutdown(), on POSIX sockets Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2012-01-12 12:57 -0700
Re: EOF, close(), shutdown(), on POSIX sockets Kaz Kylheku <kaz@kylheku.com> - 2012-01-12 20:04 +0000
csiph-web