Hi Folks,
I read the following:
"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.)"
in the "How to communicate with other applications using sockets" tutorial at:
http://runrev.screenstepslive.com/s/les ... ng-sockets
but I can not find any examples of how to get at the result to see if there was an error, i.e. bad hostname, no such ipaddr, etc. I also am assuming that if the server should be down the connection attempt would result in a socketTimeout message; is that assumption correct?
Any help figuring this out would be much appreciated.
Thanks,
Daryl
testing for socket error
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: testing for socket error
Daryl,
SocketTimeout is sent if a socket exists but somehow doesn't respond to an open socket, write to socket or read from socket command.
Kind regards,
Mark
Code: Select all
-- put this into a mouseUp handler for instance
put "123.45.67.89:80" into mySock
open socket to mySock
put the result into rslt
if rslt is not empty then
write "helo" to socket mySock
read from sockey mySock with msg "msgReceived"
else
beep
answer error rslt
-- doesn't matter if socket is already closed
close socket mySock
end if
-- put this in the same button as the mouseUp handler
-- or higher up the message hierarchy
on socketError theSock,theError
beep
answer error theError
end socketError
Kind regards,
Mark
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
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: testing for socket error
Hi,
What you say in your previous message is not true. It's what it's descibed in Livecode documentation and articles but when you made a socket connection to an existing host which doesn't have opened this port, the result is empty. Same on a server which has opened this port. And the "socketError" is never sent (in the two cases).
Best, Guy
What you say in your previous message is not true. It's what it's descibed in Livecode documentation and articles but when you made a socket connection to an existing host which doesn't have opened this port, the result is empty. Same on a server which has opened this port. And the "socketError" is never sent (in the two cases).
Best, Guy