Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

A simple networking question

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
4 replies to this topic

#1 GameCodingNinja   Members   

285
Like
0Likes
Like

Posted 15 October 2012 - 09:40 AM

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!

#2 frob   Moderators   

44018
Like
0Likes
Like

Posted 15 October 2012 - 10:47 AM

Servers need to have a fixed inbound port for the listening system. This is specified in your program.

Generally apps that connect to the server don't care about the outbound port and let the system use any random unused port.

Check out my book, Game Development with Unity, aimed at beginners who want to build fun games fast.

Also check out my personal website at bryanwagstaff.com, where I occasionally write about assorted stuff.


#3 GameCodingNinja   Members   

285
Like
0Likes
Like

Posted 15 October 2012 - 12:02 PM

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.

#4 0BZEN   Members   

2195
Like
0Likes
Like

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.

Everything is better with Metal.


#5 rip-off   Moderators   

10885
Like
0Likes
Like

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.




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.