I have a multi-threaded client. Each thread opens a socket
connection to a remote server. The connection is made in the
constructor to class Socket:

        Socket mysock = new Socket(host, port);

... where 'host' is a String.

When several clients initialize (and connect their sockets) at
the same time, occasionally one will fail. The Socket constructor
will throw java.net.SocketException with the message:

   errno: 4, error: Interrupted system call for fd: <n>

I tried wrappering the call with a class-synchronized method, the
idea being to prevent 2 threads from attempting to connect sockets
at the same time:

  private static synchronized Socket doConnect(String host, int port)
  {
    return new Socket host, port);
  }


But it doesn't work. I still get the same SocketException.

Is this a bug in the implementation? I'm using the Sun Java JDK
RC2 on a Linux PC, which I understand is a derivative of the
blackdown port that uses green-threads.

I can't just catch SocketException and try again, because it might
also mean something non-recoverable like connection-refused, or
network-unreachable right? And parsing the string for the errno 
value is obviously a no-no.

Why isn't it generating InterruptedIOException, or just plain
InterruptedException?

Any help is greatly appreciated.

-- 
Michael Maloney
Ilex Engineering, Inc.

  Tel: 410.241.5248
Email: [EMAIL PROTECTED]


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to