[Gambas-user] Gambas 3 advancement
Benoît Minisini
gambas at ...1...
Tue Dec 21 18:44:10 CET 2010
> Benoît Minisini ha scritto:
> >> Pipes should not return EOF when the pipe is not closed. But they should
> >> return EOF when the other side closes.
> >
> > Why ?
>
> Because this is the way *all* unix routines work, and the only logical one.
>
> > EOF() actually means "there is nothing to read anymore", which is the
> > important needed information.
>
> Indeed: it means "nothing anymore", not "nothing at the moment".
>
> > If Eof() returns TRUE only when the pipe is closed:
> >
> > 1) How do you know that there is nothing to read anymore?
>
> I know that there is nothing to read now, and in the future too, if
> eof() is true. If eof() is false, I know that some data could arrive, if
> not now, in the future. Try "cat", one of the simplest unix commands. It
> knows very well when there is data to read, when there is not, and when
> the pipe is closed.
>
> > 2) What do you do for Sockets, for example?
>
> The same as pipes. If there is data to read, I read it. If there is not,
> I don't. If eof() is true, I close my local socket because the other
> peer has closed. May be I am missing something -- using your ideas, how
> can you tell that a pipe (or a remote socket) is closed or not?
>
You get a point, but Eof() in Gambas does not actually mean what EOF means in
Unix.
I had only one Basic syntax for that, and I need to know if there is something
to read on a stream, and I used Eof() for that.
For a file stream, the two meanings are the same. But not for a pipe or a
socket.
At the moment, for a pipe or a socket, you get an error when it is closed.
Note that for a socket, "there is date to read" does not mean the same thing
than for a pipe, because there is the network between two sides of a socket.
I will try to change the meaning of Eof() to match the Unix one, and see how
many things break.
And I will keep the meaning of Lof(), so that Lof() = 0 means that there is
nothing to read, even if the new Eof() is False.
Regards,
--
Benoît Minisini
More information about the User
mailing list