I found that when I use connect(host, port), it will
invoke createSocket() in Class DefaultSocketFactory:
public Socket createSocket(String host, int port)
throws UnknownHostException, IOException
{
return new Socket(host, port);
}
But "new Socket(host, port)" function will connect ftp
server with timeout = 0, it will spend long time to
connect a null host.
When I modified the code as following, it looks that
resolved it.
public Socket createSocket(String host, int port)
throws UnknownHostException, IOException
{
//return new Socket(host, port);
Socket s = new java.net.Socket();
java.net.InetSocketAddress addr = new
java.net.InetSocketAddress(host, port);
s.connect(addr, 5000);
return s;
}
To all: Is it correct??? Any comments are welcome!
--- aha <[EMAIL PROTECTED]> wrote:
> Hi,
>
> When I use connect("10.0.0.1", 21) to connect "null"
> host, that means no host bind the "10.0.0.1", it
> throws exception after spent long time (about 220s).
>
> Faint!
>
>
> 2001-06-09 19:34:49.117 start
>
> java.net.ConnectException: Connection timed out
> at
> java.net.PlainSocketImpl.socketConnect(Native
> Method)
> at
>
java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
> at
>
java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
> at
>
java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
> at java.net.Socket.connect(Socket.java:434)
> at java.net.Socket.connect(Socket.java:384)
> at java.net.Socket.<init>(Socket.java:291)
> at java.net.Socket.<init>(Socket.java:119)
> at
>
org.apache.commons.net.DefaultSocketFactory.createSocket(DefaultSocketFactory.java:92)
> at
>
org.apache.commons.net.SocketClient.connect(SocketClient.java:201)
> ......
>
> 2001-06-09 19:38:33.792 end
>
>
>
> How can I avoid it ???
>
> B.R.
__________________________________
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]