Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.development.apps > #385

Re: EOF, close(), shutdown(), on POSIX sockets

From Andrei Voropaev <avorop@mail.ru>
Newsgroups comp.os.linux.development.apps
Subject Re: EOF, close(), shutdown(), on POSIX sockets
Date 2012-01-12 16:07 +0000
Organization SDF Public Access UNIX System, Est. 1987
Message-ID <jen0gi$bc0$1@odin.sdf-eu.org> (permalink)
References <ylfk62gpn3hg.fsf@dd-b.net> <1br4zdh37t.fsf@pfeifferfamily.net>

Show all headers | View raw


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.

-- 
Minds, like parachutes, function best when open

Back to comp.os.linux.development.apps | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

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