Assume that I have a server directly connected to internet and a client connected to a router. The client can send messages to server since it knows the server's IP address and port. But how does the server send message back to the client? It can get the client's external IP address and port but should it send message to that port? and how does the client listen to the message,which port should it listen to? assuming no port forwarding.
1
votes
1 Answers
0
votes
I assume the difficulty is that your client is behind a NAT firewall. If that's the case, then the answer is simple: you don't. That's the entire point of NAT.
But this also assumes that you're talking about the creation of a new socket from the server to the client. If the socket already exists, you just talk over it and the stateful NAT router keeps track of the things it needs to in order to get the message through.
If neither of these answers your question, you'll need to reformulate it.