commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel F. Savarese" <>
Subject Re: [FTPClient] : No errors occured when I stop the ftp server during a transfer
Date Thu, 28 Jul 2005 22:06:29 GMT

A few clarfications.

In message <2121.>, "Rick Herr
ick" writes:
>1) Make sure you're using Java 1.4 or later.  The Socket timeouts don't
>actually do anything in 1.3 or earlier, or so I've been told.  I'm using

You only need 1.4 for connection timeouts.  If the server isn't up, a
connection attempt will fail with connection refused, so I wouldn't
anticipate that being an issue.  Socket read/write timeouts work fine
on 1.2 and 1.3.

>2) Create a custom socket factory that sets the timeout when the socket is
>created.  Basically, each one of the createSocket() methods that you

That is indeed the recommended procedure for connection timeouts if you're
using J2SE 1.4 or later.

>3) Once you've created your FTPClient object, set all of the different

>// Set the ftp timeout values on the client

setSoTimeout should be called only after a connection has been established
and affects only the control connection.  It affects the actively connected
socket.  If you call it before connecting, you'll get a NullPointerException.
setDefaultTimeout should be called before establishing a connection.  The
actual timeout specified is then automatically applied to the control
connection after it is established.  It basically saves you the trouble of
calling setSoTimeout after every connection establishment.  setDataTimeout
should be called before a data connection is established
(e.g., a file transfer) because it doesn't affect an active data connection.
It does the same thing as setDefaultTimeout, except for data connections
(i.e., the timeout for the data connection is automatically set immediately
after the data connection is established).

At any rate, given the description of the problem, setDataTimeout will
ensure a file transfer times out if the server shuts down.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message