Socket Accept/Connection Question/Problem
Alex Tweedly
alex at tweedly.net
Thu Feb 28 17:00:36 EST 2008
Dave wrote:
>
> All I want to do is to know if a Client successfully connected to a
> Server, surely this is what the openSocket command is for.
>
Not quite. The 'open socket' command does try to create the connection,
but it will not (immediately) tell you whether or not it is successful
in this attempt. From the Rev docs,
" The handler continues executing while the connection is being
established. If you use the write to socket command while the connection
is opening, the data is buffered and is sent to the host as soon as the
connection is made."
i.e. you will not get an indication of success or failure immediately.
> Surely the:
>
> open socket mySocketAddress with message "ClientSocketOpen"
>
> Statement should call "ClientSocketOpen" if the Server accepted the
> connection or call "socketError" or "socketTimeout" if there was an
> error? e.g. the Server closed the socket?
Be wary of that simple word "call". the "open socket" statement will not
"call" ClientSocketOpen even in the successful case - instead it will
result in a message being sent SOME TIME LATER to that handler. And in
the failure case, it will cause a message to either socketError or
socketTimeOut again, SOME TIME LATER.
Using the code we've discussed on the server, what you will get on the
client is a socketClosed message. The server will accept the connection,
which should result in a successful "ClientSocketOpen' and then very
quickly close it causing a subsequent 'socketClosed' message.
More information about the use-livecode
mailing list