com.continuent.tungsten.common.sockets
Class ClientSocketWrapper

java.lang.Object
  extended by com.continuent.tungsten.common.sockets.SocketWrapper
      extended by com.continuent.tungsten.common.sockets.ClientSocketWrapper

public class ClientSocketWrapper
extends SocketWrapper

Provides a wrapper for client connections via sockets. This class encapsulates logic for timeouts, SSL vs. non-SSL operation, and closing the connection. This class assumes properties required for SSL operation have been previously set before SSL sockets are allocated.

Author:
Robert Hodges

Field Summary
 
Fields inherited from class com.continuent.tungsten.common.sockets.SocketWrapper
socket
 
Constructor Summary
ClientSocketWrapper()
          Creates a new wrapper for client connections.
 
Method Summary
 void close()
          Close socket.
 java.net.Socket connect()
          Connect to the server.
 java.net.InetSocketAddress getAddress()
           
 long getConnectTimeout()
           
 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.
 long getReadTimeout()
           
 java.net.Socket getSocket()
          Returns the socket.
 boolean isUseSSL()
           
 void setAddress(java.net.InetSocketAddress address)
          Sets the address to which we should connect.
 void setConnectTimeout(int connectTimeout)
          Time in milliseconds before timeout when connecting to a server.
 void setReadTimeout(int readTimeout)
          Time in milliseconds before timeout when waiting for responses after connection.
 void setUseSSL(boolean useSSL)
          If set to true, use an SSL socket, otherwise use plain TCP/IP.
 
Methods inherited from class com.continuent.tungsten.common.sockets.SocketWrapper
setSocket, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClientSocketWrapper

public ClientSocketWrapper()
Creates a new wrapper for client connections.

Method Detail

getAddress

public java.net.InetSocketAddress getAddress()

setAddress

public void setAddress(java.net.InetSocketAddress address)
Sets the address to which we should connect.


isUseSSL

public boolean isUseSSL()

setUseSSL

public void setUseSSL(boolean useSSL)
If set to true, use an SSL socket, otherwise use plain TCP/IP.


getConnectTimeout

public long getConnectTimeout()

setConnectTimeout

public void setConnectTimeout(int connectTimeout)
Time in milliseconds before timeout when connecting to a server.


getReadTimeout

public long getReadTimeout()

setReadTimeout

public void setReadTimeout(int readTimeout)
Time in milliseconds before timeout when waiting for responses after connection.


connect

public java.net.Socket connect()
                        throws java.io.IOException
Connect to the server.

Throws:
java.io.IOException

getSocket

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

Overrides:
getSocket in class SocketWrapper

getInputStream

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

Overrides:
getInputStream in class SocketWrapper
Throws:
java.io.IOException
See Also:
SocketWrapper.getInputStream()

getOutputStream

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

Overrides:
getOutputStream in class SocketWrapper
Throws:
java.io.IOException
See Also:
SocketWrapper.getOutputStream()

close

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

Overrides:
close in class SocketWrapper