I am trying to get a loop that continues to connect to a server and creates the loop until it can connect to the said server. Once connected it puts a "1" into the "Count" variable and then exits the loop. Do you guys have any ideas on what im doing or a different way to go about this?
on openStack
open socket "192.168.15.189:12345" with message "CONNECTED"
if Count = 1 then break else
wait 5 seconds
open socket "192.168.15.189:12345" with message "CONNECTED"
if Count = 1 then break else
wait 5 seconds
open socket "192.168.15.189:12345" with message "CONNECTED"
if Count = 1 then break else
wait 5 seconds
open socket "192.168.15.189:12345" with message "CONNECTED"
if Count = 1 then break else
wait 5 seconds
open socket "192.168.15.189:12345" with message "CONNECTED"
if Count = 1 then break else
wait 5 seconds
end openStack
The syntax "wait 5 seconds" is blocking and during this time LiveCode will never be able to make a connection. Instead, you should use "wait 5 seconds with messages" but there is a better way to do this.
local lSock = "192.168.15.189:12345"
on openStack
newConnection
end openStack
on newConnection
if lSock is not among the lines of the openSockets then
open socket lSock with message "connected"
send "newConnection" to me in 5 seconds
end if
end newConnection
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode