org.apache.thrift.transport
Class TSocket

java.lang.Object
  extended by org.apache.thrift.transport.TTransport
      extended by org.apache.thrift.transport.TIOStreamTransport
          extended by org.apache.thrift.transport.TSocket

public class TSocket
extends TIOStreamTransport

Socket implementation of the TTransport interface. To be commented soon!


Field Summary
 
Fields inherited from class org.apache.thrift.transport.TIOStreamTransport
inputStream_, outputStream_
 
Constructor Summary
TSocket(java.net.Socket socket)
          Constructor that takes an already created socket.
TSocket(java.lang.String host, int port)
          Creates a new unconnected socket that will connect to the given host on the given port.
TSocket(java.lang.String host, int port, int timeout)
          Creates a new unconnected socket that will connect to the given host on the given port.
 
Method Summary
 void close()
          Closes the socket.
 java.net.Socket getSocket()
          Returns a reference to the underlying socket.
 boolean isOpen()
          Checks whether the socket is connected.
 void open()
          Connects the socket, creating a new socket object if necessary.
 void setTimeout(int timeout)
          Sets the socket timeout
 
Methods inherited from class org.apache.thrift.transport.TIOStreamTransport
flush, read, write
 
Methods inherited from class org.apache.thrift.transport.TTransport
consumeBuffer, getBuffer, getBufferPosition, getBytesRemainingInBuffer, peek, readAll, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TSocket

public TSocket(java.net.Socket socket)
        throws TTransportException
Constructor that takes an already created socket.

Parameters:
socket - Already created socket object
Throws:
TTransportException - if there is an error setting up the streams

TSocket

public TSocket(java.lang.String host,
               int port)
Creates a new unconnected socket that will connect to the given host on the given port.

Parameters:
host - Remote host
port - Remote port

TSocket

public TSocket(java.lang.String host,
               int port,
               int timeout)
Creates a new unconnected socket that will connect to the given host on the given port.

Parameters:
host - Remote host
port - Remote port
timeout - Socket timeout
Method Detail

setTimeout

public void setTimeout(int timeout)
Sets the socket timeout

Parameters:
timeout - Milliseconds timeout

getSocket

public java.net.Socket getSocket()
Returns a reference to the underlying socket.


isOpen

public boolean isOpen()
Checks whether the socket is connected.

Overrides:
isOpen in class TIOStreamTransport
Returns:
true

open

public void open()
          throws TTransportException
Connects the socket, creating a new socket object if necessary.

Overrides:
open in class TIOStreamTransport
Throws:
TTransportException - if the transport could not be opened

close

public void close()
Closes the socket.

Overrides:
close in class TIOStreamTransport