org.finj
Class FTPSocket

java.lang.Object
  extended by org.finj.FTPSocket

public class FTPSocket
extends java.lang.Object

This class wraps java.net.Socket and java.net.ServerSocket behind a common (limited) interface that mimics theirs. It only exsists to circumvent the absence of a common ancestor in their hierarchy, and to provide a transparent programming for both passive and non-passive data transfers, that require Socket and ServerSocket manipulation respectively.

Copyright (C) 2000-2008 Javier Iglesias.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Since:
v1.0.2
Version:
$Id: FTPSocket.java 47 2008-01-11 23:09:46Z jiglesias $
Author:
Javier Iglesias -- jiglesias@users.sourceforge.net

Constructor Summary
FTPSocket(java.net.ServerSocket socket)
          Constructs a new instance of this class that will wrap the socket.
FTPSocket(java.net.Socket socket)
          Constructs a new instance of this class that will wrap the socket.
 
Method Summary
 void close()
          Closes the wrapped socket.
 java.net.InetAddress getInetAddress()
          Returns the value of the wrapped socket's address field.
 java.io.InputStream getInputStream()
          Returns an input stream for the wrapped socket.
 int getLocalPort()
          Returns the value of this socket's localport field.
 java.io.OutputStream getOutputStream()
          Returns an output stream for the wrapped socket.
 boolean isServerSocket()
          Returns info on the kind of socket wrapped.
 boolean isSocket()
          Returns info on the kind of socket wrapped.
 java.lang.String toString()
          Returns a string representation of the wrapped socket.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FTPSocket

public FTPSocket(java.net.Socket socket)
Constructs a new instance of this class that will wrap the socket.

Parameters:
socket - the one to wrap.
Since:
v1.0.2

FTPSocket

public FTPSocket(java.net.ServerSocket socket)
Constructs a new instance of this class that will wrap the socket.

Parameters:
socket - the one to wrap.
Since:
v1.0.2
Method Detail

isSocket

public boolean isSocket()
Returns info on the kind of socket wrapped.

Returns:
true if wrapped socket is an instance of java.net.Socket, false if it's an instance of java.net.ServerSocket.
Since:
v1.0.2

isServerSocket

public boolean isServerSocket()
Returns info on the kind of socket wrapped.

Returns:
true if wrapped socket is an instance of java.net.ServerSocket, false if it's an instance of java.net.Socket.
Since:
v1.0.2

getLocalPort

public int getLocalPort()
Returns the value of this socket's localport field.

Returns:
the value of this socket's localport field.
Since:
v1.0.2

getInetAddress

public java.net.InetAddress getInetAddress()
Returns the value of the wrapped socket's address field.

Returns:
the value of the wrapped socket's address field.
Since:
v1.0.2

close

public void close()
           throws java.io.IOException
Closes the wrapped socket.

Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
Since:
v1.0.2

toString

public java.lang.String toString()
Returns a string representation of the wrapped socket.

Overrides:
toString in class java.lang.Object
Returns:
String representation.
Since:
v1.0.2

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Returns an input stream for the wrapped socket.

Returns:
stream from where to read.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
Since:
v1.0.2

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Returns an output stream for the wrapped socket.

Returns:
stream where to write.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
Since:
v1.0.2


Copyright © 2009. All Rights Reserved.