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

Gareth Bult gareth at ...1689...
Thu May 10 10:23:20 CEST 2007


Urm,

One (easy) answer would be to have a flag that's set if the LINE INPUT returns with a complete line.
If last (n) characters == EndOfLine then Complete = TRUE, else Complete = FALSE.

This was my solution, I've subclassed the socket (imapdsocket) and written my own line input routine that does this.
(albeit it may be a bottleneck written in Gambas as opposed to C)

Gareth.


----- Original Message -----
From: "Benoit Minisini" <gambas at ...1...>
To: "nando f" <nando_f at ...951...>, "mailing list for gambas users" <gambas-user at lists.sourceforge.net>
Sent: Wednesday, May 9, 2007 8:21:38 PM (GMT) Europe/London
Subject: Re: [Gambas-user] Strings and Network input ...

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

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Gambas-user mailing list
Gambas-user at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


-- 
Gareth Bult, Encryptec Limited
Tel: 0845 25 77033, FWD: 753977, Mob: 07891 389657
Email: gareth at ...1689...

Statements made are at all times subject to Encryptec's Terms and Conditions of Business, which are available upon request.





More information about the User mailing list