المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : P2P connections between apps in different LAN environments



C# Programming
08-26-2009, 08:40 PM
Hello!

I have created a pretty cool application that works in the office environment, it allows for people to pass text, files and voice chat between each other. Its much like the Yahoo chat or those types of apps but allows you to select several people and simultaneously send encoded data. You can see the app here:

http://www.umbrasystems.com/gcomm.php

The way it works is; there is a server who sits listening on a port, the chat clients connect to that server. As chat clients connect, the server gives a list of the other connected chat clients, and informs the existing chat clients of the newcomer, so all clients now have each others names and IP addresses. When the user(chat client) wants to send a message to one or more users, he selects them from the interface and sends the data. The data is sent P2P because each chat client has its own listening server which the sender connects to to send the data, be it text or file or whatever.

This application system works great in a LAN environment but if there is a chat client outside, lets say the boss is at home but still wants to talk to the employees, he/she can't make a P2P connection to any of the others inside the LAN. This is assuming the boss can at least connect to the server(which may sit on the outside). The way I have it now is if the P2P can not be established then all data is routed through the host.

My question is this:
Assuming all chat clients have a connection to the server, how do I make a P2P connection to other chat clients on other LANs? How do other applications like Skype or Yahoo make that connection??? (and without having to port forward). I'm sure that Skype and Yahoo messenger connect to a common server initially as well.

In my server I can see that there are 2 connections, bill and Tom, who's addresses are the same 66.75.225.55:3045 and 66.75.225.55:4033, but the server has communication with them on different ports established by their LAN's router's NAT table. Is it feasible for the chat client 'Pat', who is on a different LAN, to use the address and port established by the host to directly send data?

I would appreciate any insight on how this is done!!