edtFTPj/Free - Open-source FTP library for Java | Download


com.enterprisedt.net.ftp
Class FTPActiveDataSocket

java.lang.Object
  extended by com.enterprisedt.net.ftp.FTPActiveDataSocket
All Implemented Interfaces:
FTPDataSocket

public class FTPActiveDataSocket
extends java.lang.Object
implements FTPDataSocket

Active data socket handling class

Version:
$Revision: 1.6 $
Author:
Bruce Blackshaw

Field Summary
protected  java.net.Socket acceptedSock
          The socket accepted from server.
static java.lang.String cvsId
          Revision control id
protected  java.net.ServerSocket sock
          The underlying socket for Active connection.
 
Constructor Summary
protected FTPActiveDataSocket(java.net.ServerSocket 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.
 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 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 java.net.ServerSocket sock
The underlying socket for Active connection.


acceptedSock

protected java.net.Socket acceptedSock
The socket accepted from server.

Constructor Detail

FTPActiveDataSocket

protected FTPActiveDataSocket(java.net.ServerSocket 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 FTPDataSocket
Parameters:
millis - The length of the timeout, in milliseconds
Throws:
java.io.IOException

getLocalPort

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

Specified by:
getLocalPort in interface FTPDataSocket
Returns:
the local port number to which this socket is bound

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 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 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 FTPDataSocket
Throws:
java.io.IOException

closeChild

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

Specified by:
closeChild in interface FTPDataSocket
Throws:
java.io.IOException


Copyright (c) 2001-2007 Enterprise Distributed Technologies Ltd. All Rights Reserved.