Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: [Caml-list] Re: behaviour of Unix.shutdown_connection
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Damien Doligez <Damien.Doligez@i...>
Subject: Re: [Caml-list] Re: behaviour of Unix.shutdown_connection
>From: Xavier Leroy <Xavier.Leroy@inria.fr>

>Yes.  Basically, shutdown_connection just sends an "end of file"
>condition to the program connected to the socket on the other side.
>The other program can then finish sending what it has to send, then close
>its side of the socket.  On receiving an "end of file" on your side,
>your program knows that the data exchange is over and can (and must)
>then close the descriptors on its side.

There is only one descriptor, and it is shared between the two
channels.  Thus if you close both channels, then the descriptor gets
closed twice.  If it was reopened in-between (for example in a
multithreaded program), then some unrelated part of your program will
have its descriptor closed under its feet.

So you must close the out_channel that was returned by
Unix.open_connection, but not the in_channel; and this is true whether
you called Unix.shutdown_connection or not.


Warning: I have not tested it.

-- Damien
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr