Need some info to get started with network programming

Started by
22 comments, last by flodihn 13 years, 4 months ago
Quote:
For example if you make a peer-to-peer software, any computer has to connect to any other. That means that there must be one single way to accomplish that.

Peer to peer is impossible when both peers are behind a NAT. Peer to peer "works" because some peers are publicly addressable, i.e. they are not behind a NAT.

For games, a central server can be used to initiate NAT punch-through for two peers who are behind NATs.

Quote:
Since it can't be something like 192.168.0.65 you have to find out the real one. I don't understand the methods that are written in the FAQ, but do they, in the end, provide this correct HostName?

The only way to know your public address is to ask a machine on the public internet. There is no other way. The most common way of doing this is to have a public server which you control.

The central server can then be used to store a list of all servers looking for players. This is how matchmaking services are built.

Quote:
I don't want an extra hardware for the server, I want it to work on any computer.

Then rent a server. Or use an existing computer with an always-on, non-NATed connection as the server. If you are going through a NAT, then you aren't really on the internet and you cannot do this.

Some people get private addresses from their ISP, they can never host such a service. Others get a public IP, but the router is assigned it and it creates a NAT for the devices connected to it. You can often configure these routers to forward inbound connections to a given computer, or to forward connections on a particular port to a given computer.

I have a little machine in my house. With the correct router settings, all connections on ports I want are forwarded to it. I use a free dynamic DNS service to give me a usable hostname even when my IP is occasionally changed.

You might be able to rig up the same, at least while you are testing your game. If you ever wanted to release it, you'll have to come up with a more stable and reliable solution.
Advertisement
Quote:Original post by domok
Isn't there a way that works regardless to firewall and nat and whatever to connect to a server. I don't want an extra hardware for the server, I want it to work on any computer.


What the FAQ lists is "it."

You either have to have a server with a public IP, or you have to set up port forwarding (which is similar to a public IP, topology-wise), or you have to bounce off a server that does have a public IP or port forward set up.
enum Bool { True, False, FileNotFound };
So how can I set up port forwarding? I think I've done that in the router settings (192.168.1.1). But what does that change? Can I connect now to this computer without using a public server? If yes how?

thanks
Your router should have received a public IP from your ISP.
Its often dynamic (your ISP will change it from time to time).
It should be the same ipadress shown when you visiting http://www.ipadress.org/ (unless you are several routers).

Now from another computer you should be able to connect to that ipadress on the port you forwarded.

This topic is closed to new replies.

Advertisement