I have the following problem. My client program controls server availability on the local network (using Bonjour, but this is not a mater rally). Once the client has "noticed" the client application, the client tries to create socket: Socket(serverIP,serverPort);.
At some point, the client may lose the server (Bonjour says that the server is no longer displayed on the network). Thus, the client decides the closesocket because it is no longer valid.
At some point, the server appears again. Thus, the client tries to create a new socket associated with this server. But! The server may refuse to create this socket because it (the server) already has a socket associated with the client IP address and client port. This is because the socket was closed by the client, not the server. Could this happen? And if so, how can this problem be solved?
Well, I understand that it is unlikely that the client will try to connect to the server from the same port (client port), as the client selects its ports randomly. But it can still happen (by accident). Correctly?
Roman source
share