I want to connect two clients (via TCP/IP sockets in Java). The clients can discover each other using an intermediate server. Once the clients discover each other, there should not be any involvement of the server.
I made some study about this and found many people suggesting JXTA. But I'd like to create the protocol myself from scratch (because in future I might have to implement the same using WebSockets as well (when my client is a Browser)). Currently, my clients can be Desktop applications or mobile applications.
My questions are:
1. How will clients discover each other at the server? If the server sends the global IP address of the clients to each other, will that information be enough to create a peer-to-peer connection? What if the clients are on the same LAN network and the server is on a different WAN?
2. Client have dynamic IP address. Can their IP change all of a sudden even if it has an active socket?
3. Is peer-to-peer connection is reliable for transfer of non-continuous data (like in chat application)?
[*NOTE*: by peer-to-peer connection I mean establishing a client-server TCP/IP socket connection by making one of the client as temporary socket-server]