I am developing a Java Video chat application. I use Java socket to communicate. But it seems I have to set up the exact IP and Port to connect a socket server. My design is:
- Both client register report its ip to server and then server exchange their information.
- Choose one client(A) to be the video chat socket server and report its ip and port to server. Server will tell another client(B) his video chat server ip and port.
- Client B register itself to Client A. Now A and B can communicate directly.
Here comes problem. If A has a public Internet IP, things work well. Problem is that if client A and B are both behind a router, for example client A and B are in different University, how can they communicate with socket?