I'm basically a developer, and this is the first time i'm trying to develop a chat application over internet without any servers in between. It's easy to send data from PC to server and then to another PC. But i'm lost in search of direct communication (Peer 2 Peer - i don't know that this is correct term.). While searching i came across the concept of UDP, TCP. But in all the examples they used computers in same network. I don't know how to connect exactly the computer that i want which is connected to router along with hundreds of PCs. I came across Ports and stuffs. But it confused me a lot. To make this whole thing simple. I just want to transfer data between two PCs over internet inspite of how they connected to the internet.
Simple answer is, It is not possible. So you have to have VPN connection or Central Server for Communications.
In your Requirement, You have two option.
- Chat between User Accounts
- Direct peer 2 peer chat application. (Connection looks like a teamweaver)
I think First option is very easy to implement and develop. Second option is very complicated.
Teamweaver is looks like a peer 2 peer connection. But Actually it is connected to central server. It does not allowed to access computer directly. So you need to have central server for authentication.
Otherwise You have to have Static IP address from both device. Because TCP cannot keep status when changing IP address. When you establish TCP connection it will use IP address + Port address. Therefore you cannot have stable connection when ip is changed.