Click here to Skip to main content
15,886,745 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
Hi,
I want to write a Chat application. I have found 100 of tutorials but every one was just a local chat. But I want to write a Chat ´with users and which can but dont have to be in the same network. I want to write a chat which is like Skype, ICQ, MSN, and so on....
But I dont know how! How can I create a connection beteen two computers which arent in the same network?



Best regards
Andre
Posted

You make a connection exactly the same as on a local network. There are however additional obstacles that you may need to overcome, such as firewalls and routers.

To connect two computers that are behind firewalls or routers you will need a server that is directly connected to the internet (not behind any routers, or set as the DMZ server, or has port forwarding set up for ports that your application will be using) that will facilitate the connection of the two computers.
You can find a ton of tutorials for getting past routers by searching for 'NAT Traversal'. Be aware that you cannot always connect two computers due to the way that the routers may be set up, or because a firewall is blocking the connection.
 
Share this answer
 
v2
Comments
Dalek Dave 12-Oct-10 9:25am    
Good Call
Mostafa Elsadany 17-Sep-11 5:11am    
there is any code ?
TcpClient tcpclnt = new TcpClient("196.221.94.166", 8001);


NetworkStream mynetsream = tcpclnt.GetStream();

StreamWriter myswrite = new StreamWriter(mynetsream);
myswrite.WriteLine(TextBox1.Text);
myswrite.Close();
mynetsream.Close();
tcpclnt.Close();
what a problem in this to work on Internet
You can use socket connection. For this you have to need a server pc, which have a real ip. all client application know the server ip & port. each client connect each other via the server.
 
Share this answer
 
You can use socket connection. For this you have to need a server pc, which have a real ip. all client application know the server ip & port. each client connect each other via the server.
 
Share this answer
 
The routers have to be configured to allow your traffic (with the protocoal and on the ports you selected). The router itself should automatically handle the NAT requirements - all you have to do is establish the connection between the two computers. Keep in mind that NAT allows several computers to exist behind a single IP address, and traffic meant for a given computer behind the router will be routed to that computer.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900