|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
org.globus.ftp.vanilla
Class FTPControlChannel
java.lang.Objectorg.globus.ftp.vanilla.BasicClientControlChannel
org.globus.ftp.vanilla.FTPControlChannel
- Direct Known Subclasses:
- GridFTPControlChannel
- public class FTPControlChannel
- extends BasicClientControlChannel
Represents FTP Protocol Interpreter. Encapsulates control channel communication.
| Field Summary | |
static String |
CRLF
|
protected BufferedReader |
ftpIn
|
protected OutputStream |
ftpOut
|
protected boolean |
hasBeenOpened
|
protected String |
host
|
protected int |
port
|
protected InputStream |
rawFtpIn
|
protected Socket |
socket
|
| Constructor Summary | |
FTPControlChannel(InputStream in,
OutputStream out)
Using this constructor, you can initialize an instance that does not talk directly to the socket. |
|
FTPControlChannel(String host,
int port)
|
|
| Method Summary | |
void |
close()
Closes the control channel |
Reply |
exchange(Command cmd)
Write the command to the control channel, block until reply arrives and return the reply. |
Reply |
execute(Command cmd)
Write the command to the control channel, block until reply arrives and check if the command completed successfully (reply code 200). |
protected void |
finalize()
|
protected BufferedReader |
getBufferedReader()
|
String |
getHost()
|
protected OutputStream |
getOutputStream()
|
int |
getPort()
|
protected boolean |
hasBeenOpened()
|
protected boolean |
haveStreams()
|
void |
open()
opens the connection and returns after it is ready for communication. |
Reply |
read()
Block until a reply is available in the control channel. |
protected void |
readInitialReplies()
|
protected void |
setInputStream(InputStream in)
|
protected void |
setOutputStream(OutputStream out)
|
void |
waitFor(Flag aborted,
int ioDelay,
int maxWait)
Block until one of the conditions are true: a reply is available in the control channel, timeout (maxWait) expired aborted flag changes to true. |
void |
write(Command cmd)
Sends the command over the control channel. |
protected void |
writeln(String msg)
|
protected void |
writeStr(String msg)
|
| Methods inherited from class org.globus.ftp.vanilla.BasicClientControlChannel |
waitFor |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
CRLF
public static final String CRLF
- See Also:
- Constant Field Values
socket
protected Socket socket
ftpIn
protected BufferedReader ftpIn
rawFtpIn
protected InputStream rawFtpIn
ftpOut
protected OutputStream ftpOut
host
protected String host
port
protected int port
hasBeenOpened
protected boolean hasBeenOpened
| Constructor Detail |
FTPControlChannel
public FTPControlChannel(String host, int port)
FTPControlChannel
public FTPControlChannel(InputStream in, OutputStream out)
- Using this constructor, you can initialize an instance that does not
talk directly to the socket. If you use this constructor using streams
that belong to an active connection, there's no need to call open() afterwards.
| Method Detail |
getHost
public String getHost()
getPort
public int getPort()
getBufferedReader
protected BufferedReader getBufferedReader()
getOutputStream
protected OutputStream getOutputStream()
setInputStream
protected void setInputStream(InputStream in)
setOutputStream
protected void setOutputStream(OutputStream out)
open
public void open()
throws IOException,
ServerException
- opens the connection and returns after it is ready for communication.
Before returning, it intercepts the initial server reply(-ies),
and not positive, throws UnexpectedReplyCodeException.
After returning, there should be no more queued replies on the line.
Here's the sequence for connection establishment (rfc959):
120 220 220 421- Throws:
IOException- on I/O errorServerException- on negative or faulty server reply
readInitialReplies
protected void readInitialReplies()
throws IOException,
ServerException
- Throws:
IOExceptionServerException
close
public void close()
throws IOException
- Closes the control channel
- Throws:
IOException
waitFor
public void waitFor(Flag aborted, int ioDelay, int maxWait) throws ServerException, IOException, InterruptedException
- Block until one of the conditions are true:
- a reply is available in the control channel,
- timeout (maxWait) expired
- aborted flag changes to true.
- Specified by:
waitForin classBasicClientControlChannel
- Parameters:
maxWait- timeout in milisecondsioDelay- frequency of polling the control channel and checking the conditionsaborted- flag indicating wait aborted.- Throws:
ServerExceptionIOExceptionInterruptedException
read
public Reply read() throws ServerException, IOException, FTPReplyParseException
- Block until a reply is available in the control channel.
- Specified by:
readin classBasicClientControlChannel
- Returns:
- the first unread reply from the control channel.
- Throws:
IOException- on I/O errorFTPReplyParseException- on malformatted server replyServerException
write
public void write(Command cmd) throws IOException, IllegalArgumentException
- Sends the command over the control channel.
Do not wait for reply.
- Parameters:
cmd- FTP command- Throws:
IOException- on I/O errorIllegalArgumentException
exchange
public Reply exchange(Command cmd) throws ServerException, IOException, FTPReplyParseException
- Write the command to the control channel,
block until reply arrives and return the reply.
Before calling this method make sure that no old replies are
waiting on the control channel. Otherwise the reply returned
may not be the reply to this command.
- Parameters:
cmd- FTP command- Returns:
- the first reply that waits in the control channel
- Throws:
IOException- on I/O errorFTPReplyParseException- on bad reply formatServerException
execute
public Reply execute(Command cmd) throws ServerException, IOException, FTPReplyParseException, UnexpectedReplyCodeException
- Write the command to the control channel,
block until reply arrives and check if the command
completed successfully (reply code 200).
If so, return the reply, otherwise throw exception.
Before calling this method make sure that no old replies are
waiting on the control channel. Otherwise the reply returned
may not be the reply to this command.
- Parameters:
cmd- FTP command- Returns:
- the first reply that waits in the control channel
- Throws:
IOException- on I/O errorFTPReplyParseException- on bad reply formatUnexpectedReplyCodeException- if reply is not a positive completion reply (code 200)ServerException
finalize
protected void finalize()
writeln
protected void writeln(String msg) throws IOException
- Throws:
IOException
writeStr
protected void writeStr(String msg) throws IOException
- Throws:
IOException
hasBeenOpened
protected boolean hasBeenOpened()
haveStreams
protected boolean haveStreams()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
