Package org.apache.thrift.transport
Class TSocket
java.lang.Object
org.apache.thrift.transport.TTransport
org.apache.thrift.transport.TEndpointTransport
org.apache.thrift.transport.TIOStreamTransport
org.apache.thrift.transport.TSocket
- All Implemented Interfaces:
Closeable,AutoCloseable
Socket implementation of the TTransport interface. To be commented soon!
-
Field Summary
Fields inherited from class org.apache.thrift.transport.TIOStreamTransport
inputStream_, outputStream_Fields inherited from class org.apache.thrift.transport.TEndpointTransport
knownMessageSize, remainingMessageSize -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new unconnected socket that will connect to the given host on the given port.Creates a new unconnected socket that will connect to the given host on the given port.Constructor that takes an already created socket.TSocket(TConfiguration config, String host, int port) Creates a new unconnected socket that will connect to the given host on the given port.TSocket(TConfiguration config, String host, int port, int timeout) Creates a new unconnected socket that will connect to the given host on the given port.TSocket(TConfiguration config, String host, int port, int socketTimeout, int connectTimeout) Creates a new unconnected socket that will connect to the given host on the given port, with a specific connection timeout and a specific socket timeout. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the socket.Returns a reference to the underlying socket.booleanisOpen()Checks whether the socket is connected.voidopen()Connects the socket, creating a new socket object if necessary.voidsetConnectTimeout(int timeout) Sets the time after which the connection attempt will time outvoidsetSocketTimeout(int timeout) Sets the socket timeoutvoidsetTimeout(int timeout) Sets the socket timeout and connection timeout.Methods inherited from class org.apache.thrift.transport.TIOStreamTransport
flush, read, writeMethods inherited from class org.apache.thrift.transport.TEndpointTransport
checkReadBytesAvailable, countConsumedMessageBytes, getConfiguration, getMaxFrameSize, getMaxMessageSize, resetConsumedMessageSize, setMaxFrameSize, updateKnownMessageSizeMethods inherited from class org.apache.thrift.transport.TTransport
consumeBuffer, getBuffer, getBufferPosition, getBytesRemainingInBuffer, peek, read, readAll, write, write
-
Constructor Details
-
TSocket
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
Creates a new unconnected socket that will connect to the given host on the given port.- Parameters:
config- check confighost- Remote hostport- Remote port- Throws:
TTransportException
-
TSocket
Creates a new unconnected socket that will connect to the given host on the given port.- Parameters:
host- Remote hostport- Remote port- Throws:
TTransportException
-
TSocket
Creates a new unconnected socket that will connect to the given host on the given port.- Parameters:
host- Remote hostport- Remote porttimeout- Socket timeout and connection timeout- Throws:
TTransportException
-
TSocket
public TSocket(TConfiguration config, String host, int port, int timeout) throws TTransportException Creates a new unconnected socket that will connect to the given host on the given port.- Parameters:
config- check confighost- Remote hostport- Remote porttimeout- Socket timeout and connection timeout- Throws:
TTransportException
-
TSocket
public TSocket(TConfiguration config, String host, int port, int socketTimeout, int connectTimeout) throws TTransportException Creates a new unconnected socket that will connect to the given host on the given port, with a specific connection timeout and a specific socket timeout.- Parameters:
config- check confighost- Remote hostport- Remote portsocketTimeout- Socket timeoutconnectTimeout- Connection timeout- Throws:
TTransportException
-
-
Method Details
-
setTimeout
public void setTimeout(int timeout) Sets the socket timeout and connection timeout.- Parameters:
timeout- Milliseconds timeout
-
setConnectTimeout
public void setConnectTimeout(int timeout) Sets the time after which the connection attempt will time out- Parameters:
timeout- Milliseconds timeout
-
setSocketTimeout
public void setSocketTimeout(int timeout) Sets the socket timeout- Parameters:
timeout- Milliseconds timeout
-
getSocket
Returns a reference to the underlying socket. -
isOpen
public boolean isOpen()Checks whether the socket is connected.- Overrides:
isOpenin classTIOStreamTransport- Returns:
- false after close is called.
-
open
Connects the socket, creating a new socket object if necessary.- Overrides:
openin classTIOStreamTransport- Throws:
TTransportException- if the transport could not be opened
-
close
public void close()Closes the socket.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classTIOStreamTransport
-