Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 78110 invoked from network); 15 Jun 2004 06:52:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 15 Jun 2004 06:52:15 -0000 Received: (qmail 3245 invoked by uid 500); 15 Jun 2004 06:52:06 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 3170 invoked by uid 500); 15 Jun 2004 06:52:06 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 3139 invoked by uid 99); 15 Jun 2004 06:52:06 -0000 Received: from [216.136.131.235] (HELO web11405.mail.yahoo.com) (216.136.131.235) by apache.org (qpsmtpd/0.27.1) with SMTP; Mon, 14 Jun 2004 23:52:06 -0700 Message-ID: <20040615065124.69397.qmail@web11405.mail.yahoo.com> Received: from [218.108.48.167] by web11405.mail.yahoo.com via HTTP; Mon, 14 Jun 2004 23:51:24 PDT Date: Mon, 14 Jun 2004 23:51:24 -0700 (PDT) From: aha Subject: RE: [net]FTPClient.connect() spend long time for "null" host To: commons-user@jakarta.apache.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N 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 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.(Socket.java:291) > at java.net.Socket.(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: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org