com.continuent.tungsten.common.sockets
Class SocketWrapper

java.lang.Object
  extended by com.continuent.tungsten.common.sockets.SocketWrapper
Direct Known Subclasses:
ClientSocketWrapper

public class SocketWrapper
extends java.lang.Object

Implements methods common to both client and server sockets. It provides common methods for obtaining input and output streams on both socket types as well as closing the socket. This class works around the fact that the Java NIO Channel provides an incomplete abstraction for networking that does not support SSL operation.

Author:
Robert Hodges

Field Summary
protected  java.net.Socket socket
           
 
Method Summary
 void close()
          Close socket.
 java.io.InputStream getInputStream()
          Returns an input stream that can read data from the socket.
 java.io.OutputStream getOutputStream()
          Returns an output stream that can write data to the socket.
 java.net.Socket getSocket()
          Returns the socket.
 void setSocket(java.net.Socket socket)
          Sets the socket.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

socket

protected java.net.Socket socket
Method Detail

setSocket

public void setSocket(java.net.Socket socket)
Sets the socket. This is used by clients sockets, which do not know the socket type until they connect.


getSocket

public java.net.Socket getSocket()
Returns the socket.


getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Returns an input stream that can read data from the socket.

Throws:
java.io.IOException

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Returns an output stream that can write data to the socket.

Throws:
java.io.IOException

close

public void close()
Close socket. This is synchronized to prevent accidental double calls.


toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()