Ashiq
Ashiq

Reputation: 41

P2P chat application which works on wide network over internet

I want to build a p2p mobile phone chat application which can connect different users accross the globe over internet.I searched the web but didnt comeacross anything i specifically want to. I found somany p2p approaches using wifi,bluetooth,nfc etc but these can only be implemented in small area only. I also found an approach that only uses a server to update the address of connected devices.But i want to build a chat application which is completely without any servers and users accross different part should be able to connect over internet. I dont know any connection establishment mechanism if exist to do so. Please help me to find a solution.

Upvotes: 2

Views: 1104

Answers (1)

MartinZ
MartinZ

Reputation: 325

This is not a new subject anymore, people have spent a lot of time on this subject, but there is still no perfect solution.

NAT prevents us to connect to each other directly.

Let me try to explain it:

Just assume you have two peers A, B, which want to establish a connection.

In a real network environment, A and B will be both behind the NAT, so they cannot connect to other with the local area network IP address(such as 192.168.. or, 10.0..).

To solve the above problem, people try to fire a public servers(C) to get the public IP addresses of A and B.

(1) A connects to C, we can get A's public IP address from the C.

(2) B connects to C, we can get B's public IP address from the C.

(3) Then C sends A's public IP to B, sends B's public IP to A. After that, A and B get the public IP of each other.

(4) Then A and B can establish a connection with the public IPs.

But that depends on the NAT's implementation.

For some types of NAT implementation, the A and B's public IPs may change. The public IPs of A/B will keep unchanged only if the current connection is not disconnected, which means even if we exchange the A/B's public IPs to each other by Server C, A and B cannot connect to each other.

Explaining the NAT in detail may need a lot of words, please ref https://en.wikipedia.org/wiki/Network_address_translation. section "NAT implementation classifications".

Upvotes: 2

Related Questions