TCP Socket reconnection using same local part
I've a problem with TCP Sockets.
When my client lost the network connection with the server, it tries to create a new Socket and connect again. (It's trying to create a connection every five seconds)
When the network connection is ok, the application creates a new Socket, it connects with the server, and closes the first socket, but when the client send messages to it, the server is not sending the answers to the new socket.
I saw that server sends the answers to the port of the closed socket and not to the connected socket port.
I can't modify the server because I have not the source code. I need solve the problem modifying the client.
It's possible to connect with server always with the same local port? How? I tried to set setReuseAddress to true but the local port of the socket is always diffrenet.
If isn't possible to do this. How can I force to server to send messages/answers to new local port?