views:

45

answers:

1

Hey guys I had some questions about udp networking. First of all how can two computers that are on separate networks connect to each other? I know that you can do this with port forwarding but I know things like xbox live don't work through that. How is this possible and is there a way to obtain an address to another computer on a separate network?

EDIT

Ok thanks for the help I am using objc so I ended up using asyncsocket and portmapper for doing router configuration.

http://code.google.com/p/cocoaasyncsocket/

http://www.codingmonkeys.de/portmap/

+2  A: 

First, obtaining the public IP of a remote computer:

  • Use dynamic dns.
  • Make your own protocol and run a server to keep the list of users and IP.

Working out incoming UDP packets:

  • Use client/server communication instead of peer-to-peer.
  • Use UPnP protocol (i think xbox does this) to ask your router for a port. Not all routers support or have UPnP enabled.
  • Use TURN/STUN protocol. This protocol has been designed to bypass UDP nat. This requires an external server, but there are free servers available.

I think there are libraries for UPnP and STUN, but i can't tell you for sure.

LatinSuD
Hmm this seems strange that this would be difficult because of the amount of people who use peer to peer such as iChat, skype and tons of other stuff... If they first connected to a server could the server identify some address that he could send to another client that it could use to connect with?
Justin Meiners
All those applications run both client/server and p2p communications. The first let the system know the public IP address of clients. Then the hard part is to open (forward) the ports from the external side of the router to the private address of the client pc.
LatinSuD
Ok so basically your client program just has to sort of setup port forwarding for the current connection?
Justin Meiners
Does it basicly setup this port forward when you bind the socket to a given port?
Justin Meiners
In the case of UPnP, your application first negotiates with the router an available port, then bind it.
LatinSuD