I've just started learning winsockets.
When my client computer attempts to connect to a server, I'm assuming it has picked a port to tell the server it can use to communicate back. Is this a standard port or a random one?
Thanks!
A simple networking question
Started by GameCodingNinja, Oct 15 2012 09:40 AM
4 replies to this topic
Ad:
#4 GDNet+ - Reputation: 1771
Posted 16 October 2012 - 11:47 AM
That would make sense. I'm assuming the router associates this random port with the internal IP address of the computer that sent the request.
Yes, that's standard router procedures.
(LAN IP / internet IP)
192.168.1.2:61455 <-> 3.43.125.18:12233.
You'll need port forwarding to host a game on a specific router port.
Edited by papalazaru, 16 October 2012 - 11:47 AM.
That's the coolest thing since the mullet!
#5 Moderators - Reputation: 5034
Posted 16 October 2012 - 01:58 PM
Just to be clear - there are two steps here. The client will generally generate a random port when opening the connection (usually by delegating to the operating system, not by using rand()), and the typical NAT router may further randomise this again on the way to the internet. Thus server will see the router's address and the router's chosen port, while the client will believe it is using a different port.






