edu.emory.mathcs.util.net
Class SocketWrapper

java.lang.Object
  extended byjava.net.Socket
      extended byedu.emory.mathcs.util.net.SocketWrapper
Direct Known Subclasses:
CompressedSocketWrapper

public abstract class SocketWrapper
extends java.net.Socket

Wrapper for sockets which enables to add functionality in subclasses on top of existing, connected sockets. It is useful when direct subclassing of delegate socket class is not possible, e.g. if the delegate socket is created by a library. Possible usage example is socket factory chaining. This class delegates all socket-related requests to the wrapped delegate, as of JDK 1.4.

Version:
1.4
Author:
Dawid Kurzyniec

Field Summary
protected  java.net.Socket delegate
          the wrapped delegate socket.
 
Constructor Summary
protected SocketWrapper(java.net.Socket delegate)
          Creates new socket wrapper for a given socket.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 java.nio.channels.SocketChannel getChannel()
           
 int hashCode()
           
 boolean isBound()
          Returns true, indicating that the socket is bound.
 boolean isClosed()
           
 boolean isConnected()
          Returns true, indicating that the socket is connected.
 boolean isInputShutdown()
           
 boolean isOutputShutdown()
           
 
Methods inherited from class java.net.Socket
bind, close, connect, connect, getInetAddress, getInputStream, getKeepAlive, getLocalAddress, getLocalPort, getLocalSocketAddress, getOOBInline, getOutputStream, getPort, getReceiveBufferSize, getRemoteSocketAddress, getReuseAddress, getSendBufferSize, getSoLinger, getSoTimeout, getTcpNoDelay, getTrafficClass, sendUrgentData, setKeepAlive, setOOBInline, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setSocketImplFactory, setSoLinger, setSoTimeout, setTcpNoDelay, setTrafficClass, shutdownInput, shutdownOutput, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

delegate

protected final java.net.Socket delegate
the wrapped delegate socket.

Constructor Detail

SocketWrapper

protected SocketWrapper(java.net.Socket delegate)
                 throws java.net.SocketException
Creates new socket wrapper for a given socket. The delegate must be connected and bound and it must not be closed.

Parameters:
delegate - the delegate socket to wrap
Throws:
java.net.SocketException - if the delegate socket is closed, not bound, or not connected
Method Detail

getChannel

public java.nio.channels.SocketChannel getChannel()

isBound

public boolean isBound()
Returns true, indicating that the socket is bound.

Returns:
true

isClosed

public boolean isClosed()

isConnected

public boolean isConnected()
Returns true, indicating that the socket is connected.

Returns:
true

isInputShutdown

public boolean isInputShutdown()

isOutputShutdown

public boolean isOutputShutdown()

equals

public boolean equals(java.lang.Object obj)

hashCode

public int hashCode()