I'm starting the server with a port of 0, so I can then immediately open a client of the server, without hard-wiring in a specific port. Before I start the client, I need to call getPort(). But that may not work, since the server field may not have been set yet, and that happens in a separate thread. My suggestion is to move the initial socket.bind to the start method, before the run method in the new thread. See included patch.
startserver-patch.txt
I'm starting the server with a port of 0, so I can then immediately open a client of the server, without hard-wiring in a specific port. Before I start the client, I need to call getPort(). But that may not work, since the server field may not have been set yet, and that happens in a separate thread. My suggestion is to move the initial socket.bind to the start method, before the run method in the new thread. See included patch.
startserver-patch.txt