org.globus.ftp.vanilla
public class FTPControlChannel extends BasicClientControlChannel
Represents FTP Protocol Interpreter. Encapsulates control channel communication.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CRLF |
protected java.io.BufferedReader |
ftpIn |
protected java.io.OutputStream |
ftpOut |
protected boolean |
hasBeenOpened |
protected java.lang.String |
host |
protected int |
port |
protected java.io.InputStream |
rawFtpIn |
protected java.net.Socket |
socket |
Constructor and Description |
---|
FTPControlChannel(java.io.InputStream in,
java.io.OutputStream out)
Using this constructor, you can initialize an instance that does not
talk directly to the socket.
|
FTPControlChannel(java.lang.String host,
int port) |
Modifier and Type | Method and Description |
---|---|
void |
abortTransfer() |
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 java.io.BufferedReader |
getBufferedReader() |
java.lang.String |
getHost() |
Reply |
getLastReply()
Returns the last reply received from the server.
|
protected java.io.OutputStream |
getOutputStream() |
int |
getPort() |
protected boolean |
hasBeenOpened() |
protected boolean |
haveStreams() |
boolean |
isIPv6() |
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(java.io.InputStream in) |
protected void |
setOutputStream(java.io.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(java.lang.String msg) |
protected void |
writeStr(java.lang.String msg) |
waitFor
public static final java.lang.String CRLF
protected java.net.Socket socket
protected java.io.BufferedReader ftpIn
protected java.io.InputStream rawFtpIn
protected java.io.OutputStream ftpOut
protected java.lang.String host
protected int port
protected boolean hasBeenOpened
public FTPControlChannel(java.lang.String host, int port)
public FTPControlChannel(java.io.InputStream in, java.io.OutputStream out)
public java.lang.String getHost()
public int getPort()
public boolean isIPv6()
protected java.io.BufferedReader getBufferedReader()
protected java.io.OutputStream getOutputStream()
protected void setInputStream(java.io.InputStream in)
protected void setOutputStream(java.io.OutputStream out)
public void open() throws java.io.IOException, ServerException
120 220 220 421
java.io.IOException
- on I/O errorServerException
- on negative or faulty server replyprotected void readInitialReplies() throws java.io.IOException, ServerException
java.io.IOException
ServerException
public Reply getLastReply()
public void close() throws java.io.IOException
java.io.IOException
public void waitFor(Flag aborted, int ioDelay, int maxWait) throws ServerException, java.io.IOException, java.lang.InterruptedException
waitFor
in class BasicClientControlChannel
maxWait
- timeout in milisecondsioDelay
- frequency of polling the control channel
and checking the conditionsaborted
- flag indicating wait aborted.ServerException
java.io.IOException
java.lang.InterruptedException
public Reply read() throws ServerException, java.io.IOException, FTPReplyParseException, java.io.EOFException
read
in class BasicClientControlChannel
java.io.IOException
- on I/O errorFTPReplyParseException
- on malformatted server replyServerException
java.io.EOFException
public void abortTransfer()
abortTransfer
in class BasicClientControlChannel
public void write(Command cmd) throws java.io.IOException, java.lang.IllegalArgumentException
cmd
- FTP commandjava.io.IOException
- on I/O errorjava.lang.IllegalArgumentException
public Reply exchange(Command cmd) throws ServerException, java.io.IOException, FTPReplyParseException
cmd
- FTP commandjava.io.IOException
- on I/O errorFTPReplyParseException
- on bad reply formatServerException
public Reply execute(Command cmd) throws ServerException, java.io.IOException, FTPReplyParseException, UnexpectedReplyCodeException
cmd
- FTP commandjava.io.IOException
- on I/O errorFTPReplyParseException
- on bad reply formatUnexpectedReplyCodeException
- if reply is not a positive
completion reply (code 200)ServerException
protected void writeln(java.lang.String msg) throws java.io.IOException
java.io.IOException
protected void writeStr(java.lang.String msg) throws java.io.IOException
java.io.IOException
protected boolean hasBeenOpened()
protected boolean haveStreams()