geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig Johannsen <cjo...@shaw.ca>
Subject Re: Weird build errors on SuSE 9.2
Date Sun, 31 Oct 2004 22:35:20 GMT
Hi Aaron,

"ssc.socket().accept()" throws a SocketTimeoutException, while 
"ssc.accept()" does not. One would think that they would have identical 
behaviour, but apparently not. Here's an example where the socket 
timeout works with both JDK 1.4.2_03 and JDK 1.5.

Cheers,
Craig

import java.io.IOException;
import java.net.*;
import java.nio.channels.*;

// This code hangs on some Linux systems.
public class Hang {
public static void main(String[] args) {
try {
ServerSocketChannel ssc = ServerSocketChannel.open();
ssc.configureBlocking(true);
ssc.socket().bind(new InetSocketAddress(InetAddress.getLocalHost(), 
2010),50);
ssc.socket().setSoTimeout(5000);
System.out.println("accepting...");
ssc.socket().accept();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("Finished");
}
}


Aaron Mulder wrote:

>	Now I'm having trouble under 1.5 too, on my laptop.
>
>	Looking at a thread dump, it seems like the SO_TIMEOUT is ignored, 
>and also interrupting a thread in a ServerSocketChannel blocking accept 
>doesn't have any effect at all.
>
>Aaron
>
>-- This class hangs when run:
>
>public class Temp {
>    public static void main(String[] args) {
>        try {
>            ServerSocketChannel ssc  = ServerSocketChannel.open();
>            ssc.socket().bind(new InetSocketAddress(InetAddress.getLocalHost(), 2010),50);
>            ssc.socket().setSoTimeout(5000);
>            System.out.println("accepting...");
>            ssc.accept();
>        } catch (IOException e) {
>            e.printStackTrace();
>        }
>        System.out.println("Finished");
>    }
>}
>
>-- A similar test with only a ServerSocket runs fine.
>  
>
>


Mime
View raw message