Sockets
Dave Cragg
dcragg at lacscentre.co.uk
Tue Dec 13 02:55:10 EST 2005
On 13 Dec 2005, at 01:40, Jim Hurley wrote:
> Like Graham, I too would like to thank Alex and Dave for their
> detailed discussion of sockets.
>
> I tried Dave's small handler and it worked well, but only once. I
> went into the script to insert a break point so that I could step
> through it to see how it works, but it wouldn't work a second time.
> Even after I took the break point out, it still wouldn't work.
>
> Looks like it got all wore out after one use.
I hope not. People will want their money back. :-)
The server script appears to be still running here, but I'm
connecting over an internal network, and so use a different IP
address from the one in the script I posted.
You'll have noticed a complete lack of error checking in the script I
posted, and also on the server script if you managed to retrieve it.
Error checking is lesson 2. :-) Unfortunately, I have to go Christmas
shopping shortly (I promised), so I can't do much right now. You
could add a socketError handler to the script. The sample handler in
the Rev docs (under "socketError") should be fine.
Setting a breakpoint may not be so useful. I haven't tried this
recently, but in the past I found it difficult (impossible) to use
the debugger with asynchronous behavior like this. Instead, you might
want to add lines to the script that record values to another field.
For example, add the following "log" handler
on logit pData
put pData & return after field "log"
end logit
and then add log sttaements wherever you want to inspect something.
For example:
on readLineOne pS
logit "readLineOne" && pS ##DEBUG
read from socket pS for one line with message "readmore"
end readLineOne
Cheers
Dave
More information about the use-livecode
mailing list