I want to set-up a peer to peer connection between some computers, so users can chat external Server. My first thoughts were as follows:
I make a central ServerSocket on a server, where all applications can connect to. This ServerSocket keeps track of the connected sockets (clients), and gives the IP and Port of a new connected client to all other clients.
Each client creates a new ServerSocket to which all clients can connect to. ( [http://img837.imageshack.us/img837/4659/examplefe.png] )
In other words: every client has a ServerSocket with all other clients connected to it. The messages should go via the blue lines in the images.
There is just one little problem I run on: if I test this via all different IP addresses, it works fine, but when two clients have the same (extern) IP-adress, it will not work anymore. Does someone know a smart solution for this?
So presumably your central server is using the IP address of the client to tell the other client where to connect to.
Or perhaps you have the port number for the client's ServerSocket hard-coded, and the second client on a machine can't start its ServerSocket.
I'm just guessing because all you said was "doesn't work".
Anyway what I would suggest is that the clients should choose from a range of port numbers to create their ServerSocket; keep trying different ports until one works. And then the client should communicate both their IP address and port number to the central server to notify it that the client is available to chat. And finally the server should send the client's IP address and port number to another client who wants to chat with it.