peerbase.socket
Class SocketFactory

java.lang.Object
  extended by peerbase.socket.SocketFactory
Direct Known Subclasses:
NormalSocketFactory

public abstract class SocketFactory
extends java.lang.Object

Factory for socket implementations. Used by classes of the PeerBase system to generate sockets appropriate for normal use, testing, or educational purposes.

Author:
Nadeem Abdul Hamid

Constructor Summary
SocketFactory()
           
 
Method Summary
static SocketFactory getSocketFactory()
           
abstract  SocketInterface makeSocket(java.net.Socket socket)
          Constructs a new SocketInterface object, encapsulating a standard Java API Socket object.
abstract  SocketInterface makeSocket(java.lang.String host, int port)
          Constructs a new socket object, appropriate to the purpose of the factory.
static void setSocketFactory(SocketFactory sf)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SocketFactory

public SocketFactory()
Method Detail

getSocketFactory

public static SocketFactory getSocketFactory()

setSocketFactory

public static void setSocketFactory(SocketFactory sf)

makeSocket

public abstract SocketInterface makeSocket(java.lang.String host,
                                           int port)
                                    throws java.io.IOException,
                                           java.net.UnknownHostException
Constructs a new socket object, appropriate to the purpose of the factory.

Parameters:
host - the host name
port - the port number
Returns:
a socket connection object
Throws:
java.io.IOException
java.net.UnknownHostException

makeSocket

public abstract SocketInterface makeSocket(java.net.Socket socket)
                                    throws java.io.IOException
Constructs a new SocketInterface object, encapsulating a standard Java API Socket object.

Parameters:
socket - the socket to encapsulate
Returns:
a socket connection object
Throws:
java.io.IOException