>> >>> You want to start a server on the same port on and on? >>> >> Not actually. Different port are used for different server socket. The >> logic looks like: >> // define four slots for the ports >> int serverPorts[] = new int[]{0, 0, 0, 0}; >> >> // for each slot, create a server socket, >> // and assign the actually used port for each slot. >> for each slots run a thread { >> SSLServerSocket sslServerSocket = ... >> serverPorts[nextPort] = sslServerSocket.getLocalPort(); >> ^^^^^^^^ >> } >> >> // use the actual port for each slot in client side >> if (server ready) { >> connect to the server socket (host:port) >> }
Why do you need a serverPort parameter in doServerSide()? Can it just always be 0? >> >> This fix is trying to increase the createdPorts value properly. It is >> not actually need to synchronize serverPorts. I see. Why not just synchronized on this and add a small comment? --Max