Help - P2P connection in .Net - like Yahoo does for IM

  • Thread starter Mahesh Devjibhai Dhola
  • Start date
M

Mahesh Devjibhai Dhola

Hi,

I want to develop p2p (peer-to-peer) communication connection for chat in
..Net (Lang: c# - preferable)
NOTE: if two LAN are behind their own router then also it should work as
yahoo, msn messenger works.

Let me explain scenario:
In yahoo:
- We login to yahoo server from yahoo messenger (yahoo server listens at
port 5050).
- We get list of yahoo users in our friend list of messenger.
- Let's say I am P1 with local IP (LAN) with 192.168.0.10 with some external
IP.
(At my side, I am using Internet connection sharing from one PC - let's say
it will have some external IP through which it connect my LAN to internet
and will have 192.168.0.1 IP because we have enabled ICS.)
- We double click on one ONLINE user say P2 with Local IP 192.168.0.5 (P2
will have same scenario as P1 - uses ICS)
- we write a message and send to P2 (This message is first goes to yahoo
server and then server will send it to P2 and then P1 and P2 will be
connected directly as P2P.
{I don't know how yahoo server creates P2P connection between P1 and P2})
- We get message from P2 if he write something.

Now P1 and P2 don't use Yahoo server and connected directly as P2P
connection.
P1 has started the communication for IM so P1 will have 5101 listening port
in case of Yahoo, and P2 will send message to 5101 port.

if P1 and P2 both are behind router then also the communication is possible
in case of yahoo messenger without making any change in router configuration
and both P1 and P2 can chat.
(i am sure about this with DLink router)
So, in this way P1 > 192.168.0.10:5101 (from one LAN) is connected with P2 >
192.168.0.5: xxxx (from another LAN). And both LAN is connected with
Internet through router or ICS server with an External IP uses for outer
interaction with Internet.
(I got all the information about Yahoo communication by capturing and
analyzing the network packets.)
I think this is the same case as IRC or MSN messenger also, just chat
protocols are different. Yahoo uses YMSG protocol.

Question: how this is possible with .Net?
Or if it is not possible through .Net APIs then how can we achieve the
functionality of P2P like yahoo messenger?

I have tried a lot using Sockets in .Net but still not able to solve this.
Please help me out of this.

I am able to connect P1 to P2 if P2 is on the internet with some
external/static IP but cant if it's behind router (like P2 in case of Yahoo
in above explanation).
Now if we provide some server like application then also P1 and P2 can
connect that server but how P1 will communicate with P2 as P2P
communication?
How the server or P1 can establish P2P connection with P2?

Please provide me some idea... Help me out of this....

Thanks in advance,

Mahesh Devjibhai Dhola
"Empower yourself...."
 
P

Peter Proost

Hi,

First this a vb group so probably you want get much response on c# question.
Secondly I mailed you a vb sample of a chat application in dot net, this
contains a socketclient and a socketserver you'll first have to run the
server on one pc than the client on an other pc and then the client program
will ask you the ip of the server and a username, if you enter them both it
should work :)

hth Peter
 
L

lgbjr

Peter,

Would you mind sending me the Chat Application. I've done a lot of work with
sockets for communication between a VB.NET app and some perl apps. After
doing that, it got me thinking that I'd like to setup an internal office
Messenger (similar to Yahoo, MSN, etc), but for Intra-Office communication
only. This idea is # 300 on my "Wish I had time to do this" list. But a jump
start might be enough to get started.

TIA

Lee
 
M

Mahesh Devjibhai Dhola

Hi,
This works fine. Thanking you very much.
But the main problem is i cannot use webservice.
Without webservice how i can do the same?
Have you looked at my question and explanations in it, this was needed
because i have explained the scenario.

Thanks again,
Mahesh
 
M

Mahesh Devjibhai Dhola

Thanks Peter,
Thanks for your mail.
I have few samples and i have an application also which is same as what you
have sent.
But if you will see in the explanation i have given in my mail like yahoo IM
conversations, then you will find that what is my problem!
Yahoo connects two IM without giving IP address, without IP, how i can
connect two peers?

Please have a look in explanation of the scenario, It will give better idea.

Thanks again,
Mahesh
 
G

Guest

It doesn't matter if u use webservices or not, the point is that you need
some kind of _discovery server_ that discover's the REAL IP of the clients.
Thats how yahoo and MSN do it. For example

Node 1 oServer.REGISTERME() (192.13.13.13) ----> Proxy (213.12.13.54) --THE
INTERNET ---> DiscoveryServer(239.15.16.13)

The discovery server checks WHO IS CONNECTING, its 213.12.13.54:34564 (this
is the IP to get to Node 1, not 192.13.13.13 since that is internal IP
only..) The discovery server then saves this info, so when Node 2 comes
online, and wants to talk to Node 1, Node 2 ASKS the discovery server for his
IP.

Node 2 oServer.REGISTERME() (192.76.76.76) ----> Proxy (223.12.14.22) --THE
INTERNET ---> DiscoveryServer(239.15.16.13)

Node 2 oServer.GetMyBuddies() (192.76.76.76) ----> Proxy (223.12.14.22)
--THE INTERNET ---> DiscoveryServer(239.15.16.13)

Discovery returns the Array (dataset maybe) of buddies and they're IP
addresses (the ips that are connectable..)

The discovery server can be a webservice, a raw tcp server socket, a regular
web page which receives POSTS and returns text whatever. The point is, you
need some type of TCP socket that can _look back_ at the client to see what
the REAL IP is.

Thats the only way I know how to do it. Maybe theres a way for a client to
find this info (its REAL IP) on its own, but I don't know how..

Hope that helped..

aaron sevivas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top