Socket Comm Followup - A couple of questions

Ken Ray kray at sonsothunder.com
Fri Apr 15 23:59:37 EDT 2005


On 4/15/05 10:49 PM, "Brian Yennie" <briany at qldlearning.com> wrote:

>> 1) I noticed that in Alex's examples, after the "listener" gets the
>> message
>> fired off after the "accept" has been triggered, the "read from socket"
>> command says "read from socket lSock until CR"... any reason to read
>> only a
>> line of data at a time? If I am sending over lots of data, what's the
>> good/bad thing about reading it in all at once?
> 
> As far as I know, the only thing to look out for is reading until
> empty. Myself, I gravitate towards reading one line first because a lot
> of protocols send headers in the first few lines. Often times, the
> contents of the first line(s) will determine how the remainder of the
> communication proceeds. But if you just need the whole block of data, I
> would say go ahead and read it- but make sure you either send the
> length of the data or use some sort of termination sequence, i.e.
> 
> read from socket s for 1 line
> put it into tLength
> read from socket s for tLength
> put it into tData

Thanks, Brian... that makes more sense. Or I would assume some
mutually-agreed-upon termination character could work as well, right?

>> 2) I noticed in the Rev docs under "open socket", there is a reference
>> to an
>> "ID" parameter that is "an optional connection name for the socket and
>> can
>> be any string", and has the example:
>> 
>>   open socket to "ftp.example.org:21|sendFiles"
>> 
>> Has anyone used this? And if so (or if not), how *would* one use this?
>> And
>> does this form work with UDP as well as TCP?
> 
> You can use this to make multiple client connections. For example, to
> download multiple files at the same time- as a browser or FTP program
> might.

So would that mean that you could write to "ftp.example.org:21|sendFiles",
right? And if you wanted to open another socket, you could do so to
"ftp.example.org:21|anotherSocket" and write to
"ftp.example.org:21|anotherSocket"?

Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com




More information about the use-livecode mailing list