Networking reliability

Scott Slaugh xslaugh at gmail.com
Wed May 11 14:32:08 EDT 2005


Another issue that seems to pop up occasionally is some network reliability 
issues. I am using the following script to create a request command. In the 
requesting computer I put this:

on netrequest whatinfo,whatcomputer
--Handler used to request information
set the cursor to watch
--This puts in a hash for the program to wait for, a string that
--anyone is unlikely to be requesting
put computerAddresses[whatcomputer] into whatcomputer
open socket to (whatcomputer & ":" & netRequestPort)
write (whatInfo&" [EOT]") to socket (whatcomputer & ":" & netRequestPort)
read from socket (whatcomputer & ":" & netRequestPort) until " [EOT]"
put it into theData
replace " [EOT]" with empty in theData
close socket (whatcomputer & ":" & netRequestPort)
return theData
end netrequest

In the computer to which the request is being made, this is put:
on openStack
accept connections on port netRequestPort with message gotRequest
end openStack

on gotRequest thesocket
--This is the handler executed when the data from a request command
--comes back in
read from socket theSocket until " [EOT]"
put it into theData
replace " [EOT]" with empty in theData
do ("get" && theData)
put it into theResult
put " [EOT]" after theResult
write theResult to socket theSocket
close socket theSocket
end gotRequest

Most of the time the requests make it back and forth without a problem. 
However, occasionally the requesting computer will just time out without 
having received a reply. The infuriating thing is that it will do this 
several times in a row. But as soon as I run the debugger to try and figure 
out what is going on, it works fine. Incidentally, I use " [EOT]" as an end 
of transmission string since I sometimes transmit binary data, and seemed to 
run into problems if I used just a single ASCII character. Have any of you 
been able to reliably use Revolution as a networked app? Any ideas what 
might cause these sporadic outages? Is there something I should do to 
improve my script? Thanks!

Scott Slaugh


More information about the use-livecode mailing list