socket抛出异常
InetSocketAddress isa = new InetSocketAddress(InetAddress.getLocalHost() , 3333);
ServerSocket ss = new ServerSocket();
ss.bind(isa);
ss.setSoTimeout(10000);
Socket s = null;
try
{
while(true)
{
if (ss.isClosed()) break;
s = ss.accept();
pool.execute(new sss(s));//在线程池中操作
}
System.out.println("close socket: " + ss.isClosed());
}
catch(Exception e)
{
e.printStackTrace();
}
我运行这段程序后,等待10秒,就出现了下面错误,请问该怎么办?
java.net.SocketTimeoutException: Accept timed out
at java.net.PlainSocketImpl.socketAccept(Native Method)
at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:344)
at java.net.ServerSocket.implAccept(ServerSocket.java:441)
at java.net.ServerSocket.accept(ServerSocket.java:412)
at com.nearbox.server.ServerSocketWrapper.accept(ServerSocketWrapper.java:44)
at com.nearbox.server.AbstractServerSocket.accept(AbstractServerSocket.java:41)
at com.nearbox.server.sss.main(sss.java:63)