com.enterprisedt.net.ftp.pro
Class ProFTPActiveDataSocket

java.lang.Object
  extended by com.enterprisedt.net.ftp.pro.ProFTPActiveDataSocket
All Implemented Interfaces:
com.enterprisedt.net.ftp.internal.FTPDataSocket

public class ProFTPActiveDataSocket
extends java.lang.Object
implements com.enterprisedt.net.ftp.internal.FTPDataSocket

Active data socket handling class

Version:
$Revision: 1.1 $
Author:
Bruce Blackshaw

Field Summary
protected  StreamSocket acceptedSock
          The socket accepted from server.
static java.lang.String cvsId
          Revision control id
protected  int sendBufferSize
           
protected  ProxyServerSocket sock
          The underlying socket for Active connection.
 
Constructor Summary
ProFTPActiveDataSocket(ProxyServerSocket sock)
          Constructor
 
Method Summary
protected  void acceptConnection()
          Waits for a connection from the server and then sets the timeout when the connection is made.
 void close()
          Closes underlying sockets
 void closeChild()
          Closes child socket
 java.io.InputStream getInputStream()
          If active mode, accepts the FTP server's connection - in PASV, we are already connected.
 java.net.InetAddress getLocalAddress()
          Returns the local address to which this socket is bound.
 int getLocalPort()
          Returns the local port to which this socket is bound.
 java.io.OutputStream getOutputStream()
          If active mode, accepts the FTP server's connection - in PASV, we are already connected.
 void setReceiveBufferSize(int size)
          Set the size of the data socket's receive buffer.
 void setSendBufferSize(int size)
          Set the size of the data socket's send buffer.
 void setTimeout(int millis)
          Set the TCP timeout on the underlying data socket(s).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cvsId

public static java.lang.String cvsId
Revision control id


sock

protected ProxyServerSocket sock
The underlying socket for Active connection.


acceptedSock

protected StreamSocket acceptedSock
The socket accepted from server.


sendBufferSize

protected int sendBufferSize
Constructor Detail

ProFTPActiveDataSocket

public ProFTPActiveDataSocket(ProxyServerSocket sock)
Constructor

Parameters:
sock - the server socket to use
Method Detail

setTimeout

public void setTimeout(int millis)
                throws java.io.IOException
Set the TCP timeout on the underlying data socket(s). If a timeout is set, then any operation which takes longer than the timeout value will be killed with a java.io.InterruptedException.

Specified by:
setTimeout in interface com.enterprisedt.net.ftp.internal.FTPDataSocket
Parameters:
millis - The length of the timeout, in milliseconds
Throws:
java.io.IOException

setReceiveBufferSize

public void setReceiveBufferSize(int size)
                          throws java.io.IOException
Set the size of the data socket's receive buffer.

Specified by:
setReceiveBufferSize in interface com.enterprisedt.net.ftp.internal.FTPDataSocket
Parameters:
size - must be > 0
Throws:
java.io.IOException

setSendBufferSize

public void setSendBufferSize(int size)
                       throws java.io.IOException
Set the size of the data socket's send buffer.

Specified by:
setSendBufferSize in interface com.enterprisedt.net.ftp.internal.FTPDataSocket
Parameters:
size - must be > 0
Throws:
java.io.IOException

getLocalPort

public int getLocalPort()
Returns the local port to which this socket is bound.

Specified by:
getLocalPort in interface com.enterprisedt.net.ftp.internal.FTPDataSocket
Returns:
the local port number to which this socket is bound

getLocalAddress

public java.net.InetAddress getLocalAddress()
Returns the local address to which this socket is bound.

Specified by:
getLocalAddress in interface com.enterprisedt.net.ftp.internal.FTPDataSocket
Returns:
the local address to which this socket is bound
Throws:
java.io.IOException

acceptConnection

protected void acceptConnection()
                         throws java.io.IOException
Waits for a connection from the server and then sets the timeout when the connection is made.

Throws:
java.io.IOException - There was an error while waiting for or accepting a connection from the server.

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
If active mode, accepts the FTP server's connection - in PASV, we are already connected. Then gets the output stream of the connection

Specified by:
getOutputStream in interface com.enterprisedt.net.ftp.internal.FTPDataSocket
Returns:
output stream for underlying socket.
Throws:
java.io.IOException

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
If active mode, accepts the FTP server's connection - in PASV, we are already connected. Then gets the input stream of the connection

Specified by:
getInputStream in interface com.enterprisedt.net.ftp.internal.FTPDataSocket
Returns:
input stream for underlying socket.
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Closes underlying sockets

Specified by:
close in interface com.enterprisedt.net.ftp.internal.FTPDataSocket
Throws:
java.io.IOException

closeChild

public void closeChild()
                throws java.io.IOException
Closes child socket

Specified by:
closeChild in interface com.enterprisedt.net.ftp.internal.FTPDataSocket
Throws:
java.io.IOException


Copyright © 2001-2009 Enterprise Distributed Technologies Ltd. All Rights Reserved.