[Gambas-user] Strings and Network input ...

Benoit Minisini gambas at ...1...
Wed May 9 21:21:38 CEST 2007


On mercredi 9 mai 2007, nando wrote:
> Actually, the complexity increase isn't really too much more.
>
> 1) have a public var for the receive buffer (string)
> 2) use _read for the socket to continuously append to that string
> 3) use INSTR to look for \n\r.  IF it finds it, remove the string and use
> it. -Fernando
>
>

Yes, LINE INPUT is only safe when you use file streams. When you 
use "character" streams, i.e. sockets or process output, you cannot read as 
much data as you want.

In that case, LINE INPUT takes the end of the buffer as an end of line, so you 
cannot know if you really read a full line, or just a part of it because the 
buffer is void - if the socket didn't receive the data yet, for example.

A solution could be having blocking input/output, but then your LINE INPUT may 
wait for the data until a timeout occurs (for a socket) or forever (for a 
void pipe). And this can lead to other problems.

So at the moment, I don't know how to make the situation better. If someone 
has some idea about the semantic of LINE INPUT and other stream functions, he 
is welcome!

Regards,

-- 
Benoit Minisini




More information about the User mailing list