I'm currently building an application using TCP/IP connection and app establishes connection between server and client by querying an ip address from mysql database. But let's say there are
people A and B connected to a network NET_A (220.241.XXX.XXX)
AND
people C and D connected to a network NET_B (221.221.xxx.xxx)
and if I want A and D to be connected using some sort of ip address and B and C to be connected to each others, then what kind of ip address or method should I have to use so that those people can successfully connect to each others? I've successfully connected A and B in network NET_A using local IPv4 address achieved using following code:
InetAddress thisIp =InetAddress.getLocalHost();
System.out.println("IP:"+thisIp.getHostAddress());
Also following is serversocket code:
ServerSocket ss = new ServerSocket(PORT);
ss.setSoTimeout(10000);
connection = ss.accept();
Follow is client socket code:
connection = new Socket(InetAddress.getByName(SERVER_IP), PORT);