org.tentackle.net
Class CompressedSocket

java.lang.Object
  extended by java.net.Socket
      extended by org.tentackle.net.CompressedSocket

public class CompressedSocket
extends Socket

Socket with compressing streams. Based on tentackles CompressedInput/OutputStream.

Author:
harald

Constructor Summary
CompressedSocket()
          Creates an unconnected socket, with the system-default type of SocketImpl.
CompressedSocket(String host, int port)
          Creates a compressed stream socket and connects it to the specified port number on the named host.
 
Method Summary
 void close()
          Closes this socket.
 InputStream getInputStream()
          Returns an input stream for this socket.
 OutputStream getOutputStream()
          Returns an output stream for this socket.
 
Methods inherited from class java.net.Socket
bind, connect, connect, getChannel, getInetAddress, getKeepAlive, getLocalAddress, getLocalPort, getLocalSocketAddress, getOOBInline, getPort, getReceiveBufferSize, getRemoteSocketAddress, getReuseAddress, getSendBufferSize, getSoLinger, getSoTimeout, getTcpNoDelay, getTrafficClass, isBound, isClosed, isConnected, isInputShutdown, isOutputShutdown, sendUrgentData, setKeepAlive, setOOBInline, setPerformancePreferences, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setSocketImplFactory, setSoLinger, setSoTimeout, setTcpNoDelay, setTrafficClass, shutdownInput, shutdownOutput, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CompressedSocket

public CompressedSocket(String host,
                        int port)
                 throws IOException
Creates a compressed stream socket and connects it to the specified port number on the named host.

Parameters:
host - the host name, or null for the loopback address.
port - the port number.
Throws:
IOException - if an I/O error occurs when creating the socket.
See Also:
Socket.Socket(java.lang.String, int)

CompressedSocket

public CompressedSocket()
Creates an unconnected socket, with the system-default type of SocketImpl.

See Also:
Socket.Socket()
Method Detail

getInputStream

public InputStream getInputStream()
                           throws IOException
Description copied from class: java.net.Socket
Returns an input stream for this socket.

If this socket has an associated channel then the resulting input stream delegates all of its operations to the channel. If the channel is in non-blocking mode then the input stream's read operations will throw an IllegalBlockingModeException.

Under abnormal conditions the underlying connection may be broken by the remote host or the network software (for example a connection reset in the case of TCP connections). When a broken connection is detected by the network software the following applies to the returned input stream :-

Closing the returned InputStream will close the associated socket.

Overrides:
getInputStream in class Socket
Returns:
an input stream for reading bytes from this socket.
Throws:
IOException - if an I/O error occurs when creating the input stream, the socket is closed, the socket is not connected, or the socket input has been shutdown using Socket.shutdownInput()

getOutputStream

public OutputStream getOutputStream()
                             throws IOException
Description copied from class: java.net.Socket
Returns an output stream for this socket.

If this socket has an associated channel then the resulting output stream delegates all of its operations to the channel. If the channel is in non-blocking mode then the output stream's write operations will throw an IllegalBlockingModeException.

Closing the returned OutputStream will close the associated socket.

Overrides:
getOutputStream in class Socket
Returns:
an output stream for writing bytes to this socket.
Throws:
IOException - if an I/O error occurs when creating the output stream or if the socket is not connected.

close

public void close()
           throws IOException
Description copied from class: java.net.Socket
Closes this socket.

Any thread currently blocked in an I/O operation upon this socket will throw a SocketException.

Once a socket has been closed, it is not available for further networking use (i.e. can't be reconnected or rebound). A new socket needs to be created.

Closing this socket will also close the socket's InputStream and OutputStream.

If this socket has an associated channel then the channel is closed as well.

Overrides:
close in class Socket
Throws:
IOException - if an I/O error occurs when closing this socket.
See Also:
Socket.isClosed()


Copyright © 2001-2008 Harald Krake, Bergstr. 48, 78098 Triberg, Germany, harald@krake.de