1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
private static class TimeoutSockectFactory implements SocketFactory
{
private int CONNECT_TIMEOUT=0;
public TimeoutSockectFactory()
{}
public TimeoutSockectFactory(int timeOut)
{this.CONNECT_TIMEOUT=timeOut;}
public Socket createSocket(String hostname, int port) throws IOException
{
Socket socket=new Socket();
socket.connect(new InetSocketAddress(hostname, port), this.CONNECT_TIMEOUT);
return socket;
}
public Socket createSocket(InetAddress hostAddress, int port) throws IOException
{
Socket socket=new Socket();
socket.connect(new InetSocketAddress(hostAddress, port), this.CONNECT_TIMEOUT);
return socket;
}
public Socket createSocket(String remoteHost, int remotePort, InetAddress localAddress, int localPort) throws IOException
{return new Socket();}
public Socket createSocket(InetAddress remoteAddress, int remotePort, InetAddress localAddress, int localPort) throws IOException
{return new Socket();}
public ServerSocket createServerSocket(int port) throws IOException
{return new ServerSocket();}
public ServerSocket createServerSocket(int port, int backlog) throws IOException
{return new ServerSocket();}
public ServerSocket createServerSocket(int port, int backlog, InetAddress bindAddress) throws IOException
{return new ServerSocket();}
}
|