How do I test if an « open socket » is working or not?
Posted: Fri Feb 12, 2016 1:47 am
Hi,
I have a server accepting connections: accept connections on port "8010" with message ...
All is fine if from the client size I made socket connections on the IP address of the server. Sending and receiving data are fine.
My problem is to discover the IP address of my server.
I make a loop on all IP adresses of connected devices in my network. I open a connection on the socket but I cannot test if the connection is opened or not.
... list contains the list of IPs adresses of connected machines in my network (for this, I use "put shell("arp -n -a") into temp")
constant kPort = 8010
put the number of lines of list into n
repeat with i=1 to n
put "Searching server... (" & i & "/" & n & ")."
put line i of list into searchIP
put searchIP&":"&kPort into ts
open socket to ts
put the result into rs
// the result is always empty for all machines, thus I cannot see if the socket is open
end repeat
in the "How to communicate with other applications using sockets" tutorial, it's written that:
"If there has been an error connecting to the server the "socketError" message will be sent. (If the error is due to a problem finding the specified host, the error message is returned in the result, and no "socketError" message is sent.)"
Thus I add a socket error handler:
on socketError pSocket, pError
answerr pError
end socketError
NEVER call this handler.
Thus, my question is "How do I test that an open socket is working or not"?
Regards, Guy
I have a server accepting connections: accept connections on port "8010" with message ...
All is fine if from the client size I made socket connections on the IP address of the server. Sending and receiving data are fine.
My problem is to discover the IP address of my server.
I make a loop on all IP adresses of connected devices in my network. I open a connection on the socket but I cannot test if the connection is opened or not.
... list contains the list of IPs adresses of connected machines in my network (for this, I use "put shell("arp -n -a") into temp")
constant kPort = 8010
put the number of lines of list into n
repeat with i=1 to n
put "Searching server... (" & i & "/" & n & ")."
put line i of list into searchIP
put searchIP&":"&kPort into ts
open socket to ts
put the result into rs
// the result is always empty for all machines, thus I cannot see if the socket is open
end repeat
in the "How to communicate with other applications using sockets" tutorial, it's written that:
"If there has been an error connecting to the server the "socketError" message will be sent. (If the error is due to a problem finding the specified host, the error message is returned in the result, and no "socketError" message is sent.)"
Thus I add a socket error handler:
on socketError pSocket, pError
answerr pError
end socketError
NEVER call this handler.
Thus, my question is "How do I test that an open socket is working or not"?
Regards, Guy