[Gambas-user] [SOLVED] Socket Horror!
nospam.nospam.nospam at ...626...
nospam.nospam.nospam at ...626...
Mon Nov 23 08:27:04 CET 2009
Some of you will know that I've had truckloads of socket horror with a proxy
server I've written in gambas. Well I had more socket horror just now.
Everything was working fine last night but not when I booted up this
afternoon.
The server socket starts and listens.
The server socket detects an incoming client connection.
The server socket is established and ready.
A connection to a remote server is established.
After some time, the client gets no response so the client closes the
connection.
The client reconnects.
The server socket starts and listens...
And round and round it went.
Socket_Read() never fired, and I know nothing changed because I was using
the proxy for several hours in runtime mode and it was running flawlessly,
then I went to bed without ever touching the source code.
It turns out that the remote server IP address had changed. It now makes
sense that Socket_Read() never fired because the client application must
wait for the server to respond, which is the correct behaviour specified by
a certain RFC, but since the server was no longer on the same IP address
there was no response; the server wasn't there, it was on some other IP
address.
I checked the server and it was on a very short lease, which explains why it
appeared to work and not work at no particular time. At one point everything
started working when I set a single property in the client socket. I now
believe that the two events (me setting the property, and the proxy starting
to work) were independent and mere coincidence was what caused it to work,
i.e. the server acquired a new lease and, it just so happens, it got the
same IP address that we expected it to have.
I have now given the server a permanent IP.
So there you have it. You now know how it is that a remote server not being
on the IP address that you expect it to be on can cause the client
Socket_Read() to never fire.
Thanks to all those who offered commonsense suggestions. I could have sorted
this problem much quicker if I had bothered to check the Status property of
the socket that connects to the remote server. But hey, it's not even in
alpha stage yet :)
More information about the User
mailing list