edu.emory.mathcs.util.net.compressed
Class CompressedSocketWrapper

java.lang.Object
  extended byjava.net.Socket
      extended byedu.emory.mathcs.util.net.SocketWrapper
          extended byedu.emory.mathcs.util.net.compressed.CompressedSocketWrapper
All Implemented Interfaces:
DecoratingSocket

public class CompressedSocketWrapper
extends SocketWrapper
implements DecoratingSocket

Socket wrappper that enables data compression over an established socket connection. The output stream associated with this socket guarantees that flush sends out all the data that has been written so far. Hence, this kind of socket can be used as a transport for request-response-based protocols, like RMI or RPC.

Author:
Dawid Kurzyniec
See Also:
CompressedOutputStream

Field Summary
protected  int bufSize
          Buffer size used for compression/decompression.
 
Fields inherited from class edu.emory.mathcs.util.net.SocketWrapper
delegate
 
Constructor Summary
CompressedSocketWrapper(java.net.Socket delegate)
          Creates new compression wrapper over an existing, bound socket.
CompressedSocketWrapper(java.net.Socket delegate, int bufSize)
          Creates new compression wrapper over an existing, bound socket, using specified buffer size for compression/decompression.
 
Method Summary
 java.net.Socket getBaseSocket()
          Returns the base socket wrapped by this socket.
 java.io.InputStream getInputStream()
           
 java.io.OutputStream getOutputStream()
           
 
Methods inherited from class edu.emory.mathcs.util.net.SocketWrapper
equals, getChannel, hashCode, isBound, isClosed, isConnected, isInputShutdown, isOutputShutdown
 
Methods inherited from class java.net.Socket
bind, close, connect, connect, getInetAddress, getKeepAlive, getLocalAddress, getLocalPort, getLocalSocketAddress, getOOBInline, 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

bufSize

protected final int bufSize
Buffer size used for compression/decompression.

Constructor Detail

CompressedSocketWrapper

public CompressedSocketWrapper(java.net.Socket delegate)
                        throws java.net.SocketException
Creates new compression wrapper over an existing, bound socket.

Parameters:
delegate - the socket to enable compression for
Throws:
java.net.SocketException - if a socket exception occurs

CompressedSocketWrapper

public CompressedSocketWrapper(java.net.Socket delegate,
                               int bufSize)
                        throws java.net.SocketException
Creates new compression wrapper over an existing, bound socket, using specified buffer size for compression/decompression.

Parameters:
delegate - the socket to enable compression for
bufSize - buffer size used for compression/decompression
Throws:
java.net.SocketException - if a socket exception occurs
Method Detail

getBaseSocket

public java.net.Socket getBaseSocket()
Description copied from interface: DecoratingSocket
Returns the base socket wrapped by this socket.

Specified by:
getBaseSocket in interface DecoratingSocket
Returns:
the base socket

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Throws:
java.io.IOException

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Throws:
java.io.IOException