caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Re:  [Caml-list] Re: behaviour of Unix.shutdown_connection
@ 2001-02-15 14:20 Damien Doligez
  2001-02-15 14:35 ` Daniel de Rauglaudre
  0 siblings, 1 reply; 3+ messages in thread
From: Damien Doligez @ 2001-02-15 14:20 UTC (permalink / raw)
  To: caml-list

>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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] Re: behaviour of Unix.shutdown_connection
  2001-02-15 14:20 [Caml-list] Re: behaviour of Unix.shutdown_connection Damien Doligez
@ 2001-02-15 14:35 ` Daniel de Rauglaudre
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel de Rauglaudre @ 2001-02-15 14:35 UTC (permalink / raw)
  To: Damien Doligez; +Cc: caml-list

On Thu, Feb 15, 2001 at 03:20:41PM +0100, Damien Doligez wrote:

> 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.

If you proved it correct, no problem.

-- 
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Caml-list] Re: behaviour of Unix.shutdown_connection
  2001-02-12 13:52 Alan Schmitt
@ 2001-02-15 10:43 ` Xavier Leroy
  0 siblings, 0 replies; 3+ messages in thread
From: Xavier Leroy @ 2001-02-15 10:43 UTC (permalink / raw)
  To: caml-list, Alan.Schmitt

> If I open a connection with Unix.open_connection, and shut it down
> with Unix.shutdown_connection, do I still need to call close_in and
> close_out on the two channels ? 

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.

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-02-15 14:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-02-15 14:20 [Caml-list] Re: behaviour of Unix.shutdown_connection Damien Doligez
2001-02-15 14:35 ` Daniel de Rauglaudre
  -- strict thread matches above, loose matches on Subject: below --
2001-02-12 13:52 Alan Schmitt
2001-02-15 10:43 ` [Caml-list] " Xavier Leroy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).