I'm attempting to establish a connection between two computers over the internet using winsocket2 library. Both the client and the server are behind a router.

What do I need for the connection to succeed? do both the client and server need to use port-forwarding? or only the server needs port-forwarding?


Only the router at the server side will need a port forward. Let's look at it another way: when will the destined host become ambiguous? At the server side, because the client connects to 1 external IP address, but there are multiple possible hosts this could eventually go to. If there's no mapping in the router that says, for example, TCP port 80 must be forwarded to host x, said router won't know what to do because there are multiple possibilities and it can't just choose one at random.

Because a picture can say a thousand words: Portforwarding

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy