[Ecls-list] Closing BSD-SOCKET when a stream has been created
Goffioul Michael
goffioul at imec.be
Mon Feb 14 06:18:58 UTC 2005
> Goffioul Michael wrote:
>
> >If I'm right, the socket is not closed properly on (socket-close...)
> >when a stream has been created. The reason is that the code relies
> >on the fact that closing the stream should close the socket as well,
> >but this is not the case as the stream is a two-way stream and in ECL
> >the components of a two-way stream are not closed automatically.
> >
> The point is that the two-way stream is the only place where
> the sockets
> streams themselves are referenced. This means that whenever
> the two-way
> stream is garbage collected, the components will also be marked as
> unreferenced and their associated streams closed. And as far as I can
> tell, closing a FILE stream which was opened via fdopen() will also
> close the file handled that was open with the bsd socket routines.
I know. But I find it confusing that in the context of sockets:
1) (socket-close...) may not close the socket effctively
2) (socket-close...) has 2 different behaviors, depending on whether
a stream has been opened or not:
- if a stream has been opened -> effective closing on next GC
- if no stream -> close immediately
I assume that a user expects the socket to be closed when he
calls socket-close, at least that's what I would expect.
Finally, looking at the code, it looks like close_stream does not
reset object0 of a two-way stream structure, so the input stream is
still referenced.
Michael.
More information about the ecl-devel
mailing list