A. Craig West wrote:
> This thread isn't exactly topical to Java-Linux, but I'll throw in my 2
> bits to bring
> it some closure, I hope.

I apologize for posting a non-Java-Linux topic, but I have asked this
question to all places I know that there are experienced Java
programmers.

> It is true that Socket.setSoTimeout(int timeout) causes reads to throw an
> InterruptedIOException, but the problem he is trying to solve is that it
> does NOT cause connects to throw an exception, or timeout in any other way. 
> It will timeout eventually, depending on the OS, but there is no control 
> over it.
> When I need to do this, I use another thread to check the timeout, and
> if it has expired, I close the Socket. That tends to work to unblock the 
> thread doing the connect.

How do you close the socket? The only way to connect is using the socket
constructor.. ..so how can you have a reference to invoke close() on
before
the actual constructor is finished.

> Actually, there is an On-Topic question for you... Does closing the
> Socket on the Linux JDK port cause the connect statement to throw an 
> Exception of some kind?
> I've never tried it in Linux...

I fail to see how you can have tried it at all (see above).

> 
> Juergen Sonnauer wrote:
> >
> > What about Socket.setSoTimeout(int timeout)? Should throw a
> > InterruptedIOException after specified milliseconds on read method.
> >

/Per Widerlund

Reply via email to