I have a program where I want 4 clients to each connect to a central server, and once all 4 clients connect, the server sends the information of each other client to each client, so the central server "steps out of the way" and each of the clients can directly connect to the other 3 clients. I've tried writing the Socket object of the clients but I realized that kind of nonsensical and Sockets are not serializable anyway. What's the best technique for doing this?
1 Answers
0
votes
Clients (which are also servers) need to document the ip and port they each will listen to, as some string & int, or InetAddress & int, or SocketAddress. It has nothing to do with the connection they just made to the rendez-vous server, (although the remote client IP the server sees might be the same, but not the port).
This is your protocol to invent (serialization or dataoutputstream or else, have fun). Then any client has the ip/port to open sockets to all others.