1 22 package org.jboss.net.sockets; 23 24 import java.net.ServerSocket ; 25 import java.net.Socket ; 26 import java.net.InetAddress ; 27 import java.io.IOException ; 28 29 34 public class TimeoutServerSocket extends ServerSocket 35 { 36 public TimeoutServerSocket(int port) 37 throws IOException 38 { 39 this(port, 50); 40 } 41 public TimeoutServerSocket(int port, int backlog) 42 throws IOException 43 { 44 this(port, backlog, null); 45 } 46 public TimeoutServerSocket(int port, int backlog, InetAddress bindAddr) 47 throws IOException 48 { 49 super(port, backlog, bindAddr); 50 } 51 52 public Socket accept() throws IOException 53 { 54 Socket s = super.accept(); 55 s.setSoTimeout(1000); 56 TimeoutSocket ts = new TimeoutSocket(s); 57 return ts; 58 } 59 } 60 | Popular Tags |