public class TSocket extends TIOStreamTransport
inputStream_, outputStream_
Constructor and Description |
---|
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.
|
TSocket(java.lang.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.
|
Modifier and Type | Method and Description |
---|---|
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 |
setConnectTimeout(int timeout)
Sets the time after which the connection attempt will time out
|
void |
setSocketTimeout(int timeout)
Sets the socket timeout
|
void |
setTimeout(int timeout)
Sets the socket timeout and connection timeout.
|
flush, read, write
consumeBuffer, getBuffer, getBufferPosition, getBytesRemainingInBuffer, peek, readAll, write
public TSocket(java.net.Socket socket) throws TTransportException
socket
- Already created socket objectTTransportException
- if there is an error setting up the streamspublic TSocket(java.lang.String host, int port)
host
- Remote hostport
- Remote portpublic TSocket(java.lang.String host, int port, int timeout)
host
- Remote hostport
- Remote porttimeout
- Socket timeout and connection timeoutpublic TSocket(java.lang.String host, int port, int socketTimeout, int connectTimeout)
host
- Remote hostport
- Remote portsocketTimeout
- Socket timeoutconnectTimeout
- Connection timeoutpublic void setTimeout(int timeout)
timeout
- Milliseconds timeoutpublic void setConnectTimeout(int timeout)
timeout
- Milliseconds timeoutpublic void setSocketTimeout(int timeout)
timeout
- Milliseconds timeoutpublic java.net.Socket getSocket()
public boolean isOpen()
isOpen
in class TIOStreamTransport
public void open() throws TTransportException
open
in class TIOStreamTransport
TTransportException
- if the transport could not be openedpublic void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class TIOStreamTransport