I suspect the problem lies at this "server."

This doesn't inspire much confidence either:
Quote Originally Posted by asterix48 View Post
The server waits in an endless loop for a client to connect.
The accept method of the java.net.ServerSocket object is called in the loop.
A server shouldn't be looping at all, but be sitting with the socket "listening" while in some alertable wait state.


More likely the issue here is timing and the use of the loopback address is very fast so it can "miss" those times when the TCP endpoint is available to accept a connection. Other forms of IP addresses or names go through a lengthier slower process that makes them somewhat more likely to get lucky and get a hit.

The error says it all: there is no listener to connect to.