On Wed, Jun 19, 2013 at 6:54 AM, Shiro Kawai <xxxxxx@lava.net> wrote:
>From: John Cowan <xxxxxx@mercury.ccil.org>
Subject: Re: socket-port
Date: Tue, 18 Jun 2013 17:38:31 -0400

> Shiro Kawai scripsit:
>
>> Your logic is correct, so, in Gauche, closing one of the socket ports
>> does not close the socket descriptor (it does mark the Scheme-level
>> port structure as 'closed', and it does flush the output port).
>
> It should also do a shutdown(fd, SHUT_RD) or shutdown(fd, SHUT_WR), which
> is what I was trying to say before.  The latter, for example, signals
> to the peer that no more data will be arriving.

No, it shouldn't shut down the socket, because the socket may be
shared among processes.  A parent process may want to close the
socket fd to keep number of open fd small, while a child process
may still be using it, for example.

In Chibi you specify when opening a port on a socket whether
the port is responsible for shutting down the socket.  If so, closing
or gc'ing the port will perform the appropriate shutdown for the
port's direction(s).  At the low level the default is no responsibility,
but the high-level interfaces that never expose the socket are all
responsible.

The socket itself and other file descriptors are never directly closed
by the port - they close on explicit request or on gc.

-- 
Alex