Shell Socketed
Posted: Mon Aug 04, 2008 12:00 am
I have observed some strange behaviour using the following handlers:
on chatConnect
--1) put line 2 of fIPList() & ":1987" into s
--2) put "192.168.1.12:1987" into s
******
Line 1 and 2 each put the same string into s. Line 1 is derived using the shell script whilst line 2 is as is. Uncomment Line 2 and everything works perfectly, whilst uncommenting Line 1 produces very strange behaviour - an HTML-tagged string ending up in the message delivered to the "chatConnected" handler.
Can anyone assist with an explanation for this. My work-around is to "hard-wire" the IP addresses for the time being but I was looking for a method of "discovering" the Server on the network every time a new user wants to connect.
It took simply ages to work out that invoking the shell routine seemed to precipitate this odd behaviour.
Alex
****************
open socket s with message "chatConnected"
end chatConnect
--returns a list of the available computer IPs on the LAN
--quick and dirty routine but does the job
function fIPList
*******
put shell("arp -a") into myVar
*******
filter myVar without "*incomplete*"
delete the first line of myVar
put empty into aList
repeat with i = 1 to the number of lines in myVar
get line i of myVar
set the itemdel to "("
get item 2 of it
set the itemdel to ")"
get item 1 of it
put it & cr after aList
end repeat
return aList
end fIPList
on chatConnect
--1) put line 2 of fIPList() & ":1987" into s
--2) put "192.168.1.12:1987" into s
******
Line 1 and 2 each put the same string into s. Line 1 is derived using the shell script whilst line 2 is as is. Uncomment Line 2 and everything works perfectly, whilst uncommenting Line 1 produces very strange behaviour - an HTML-tagged string ending up in the message delivered to the "chatConnected" handler.
Can anyone assist with an explanation for this. My work-around is to "hard-wire" the IP addresses for the time being but I was looking for a method of "discovering" the Server on the network every time a new user wants to connect.
It took simply ages to work out that invoking the shell routine seemed to precipitate this odd behaviour.
Alex
****************
open socket s with message "chatConnected"
end chatConnect
--returns a list of the available computer IPs on the LAN
--quick and dirty routine but does the job
function fIPList
*******
put shell("arp -a") into myVar
*******
filter myVar without "*incomplete*"
delete the first line of myVar
put empty into aList
repeat with i = 1 to the number of lines in myVar
get line i of myVar
set the itemdel to "("
get item 2 of it
set the itemdel to ")"
get item 1 of it
put it & cr after aList
end repeat
return aList
end fIPList