- #1
- 403
- 120
SO fun story, I'm working on a client server dealio!
The flow of operations should be:
Server listens on port 9999
Client connects to port 9999
Server tells Client to connect to new port # (to allow for more connections)
Server launches a thread and listens on new port #
Client disconnects from 9999 and connects to new port number
PROFIT!
I had originally got this all working where the client and the server were on the same computer.
Today I decided to start to run the clients on a different computer.
So the client connected to 9999
got the message to use the new port number
and then would get a connection refused on the reconnect. This happened like 90-95% of the time.. But occasionally just occasionally it would work??
Fast forward an hour of scratching my head trying to figure out what the heck is going on. Turns out when I ran the client on this computer the the client would run just slow enough for the server to launch the thread and listen.
When I ran it on the other laptop it was trying to connect before the listen was done on the server.
A simple reordering so the server listens before telling the client to reconnect and everything works fine!
Fun times:)
The flow of operations should be:
Server listens on port 9999
Client connects to port 9999
Server tells Client to connect to new port # (to allow for more connections)
Server launches a thread and listens on new port #
Client disconnects from 9999 and connects to new port number
PROFIT!
I had originally got this all working where the client and the server were on the same computer.
Today I decided to start to run the clients on a different computer.
So the client connected to 9999
got the message to use the new port number
and then would get a connection refused on the reconnect. This happened like 90-95% of the time.. But occasionally just occasionally it would work??
Fast forward an hour of scratching my head trying to figure out what the heck is going on. Turns out when I ran the client on this computer the the client would run just slow enough for the server to launch the thread and listen.
When I ran it on the other laptop it was trying to connect before the listen was done on the server.
A simple reordering so the server listens before telling the client to reconnect and everything works fine!
Fun times:)