views:

26

answers:

1

Hi

I am trying to connect 2 or more computers running a c# application. All TCP examples I find only show how to connect them if they are running on the same network.

My question is how to connect them over the internet?

I want to create a service like MSN but with direct connection (like a torrent software does),

any help?

regards!

+1  A: 

Connecting 2 computers over the internet should, mostly, be the same as connecting them on a LAN. Your problems will mainly be with the firewall. In your C# code, you will have to assign an IP address & port for both computers. You should ensure that your firewall will allow this port through without blocking (beware of security vulnerabilities when opening new ports).

If your computers don't have public IPs, you will also have to set up some NAT on your router. This will map a port on your router + your public IP address to your local computers IP address + port. The other computer will then configure this public IP address + port in their configuration. There is too many configurable things that have the potential to screw up to list in a single post. I'd suggest learning some basics on networks.

However, having said all that, in terms of C# code you shouldn't have to change a thing to get the program to work over the internet if it works over a LAN.

mrnye