I am working on this program that utilizes sockets.
So far, I have created all I need but I am running into this problem when performing the following steps:
I have a client and a host, and the client has to remain connected to the host.
The user can change the client's IP address so the client needs to inform the host about it's new IP.
So far, I have been able to send in the new IP to the client... but the problem I am seeing is the client freezes for roughly 10 minutes before it establishes a new connection.
1. Connection established (client 10.1.4.2, host 10.1.4.3)
2. Host IP is updated to 10.1.4.5
3. host prior to completing the IP change issues a packet/command to host with new IP.
4. Client acks the receipt of the new ip, and closes the connection (socket).
5. Client updates the socket information with the new IP
6. Client connects to host (and it seems to connect without any errors)
7. Client sends an initial handshake statement and it freezes for around 10 minutes
8. Then, it automatically receives the intial handshake ACK and from this point on, it works fine.
I can ping the host just fine....
Does anyone know why this happens?
Do I need to do any type of cleanup in addition to closing the socket and reinitializing it?
Thanks in advance.
Shouldn't you have a number in there some place like:
4.1. Host receives ack, and closes connection and goes back to listening.
Something along those lines?
oh you are good.....
I just fixed it (and that was indeed the missing step) but it is amazing that you didn't see my code to really assume that this step wasn't happening....
appreciate your reply.....
my hat off to you!!!!
The ugly twin sister of this problem is not setting the flag to re-use the address on the server and so once a socket closes, it goes into a time-wait state for ten mins before it can be reused. PITA but it happens.
thanks jeffcobb. I will keep that in mind.