DthingApi
|
Public Member Functions | |
Socket () | |
Socket (String dstName, int dstPort) throws UnknownHostException, IOException | |
Socket (String dstName, int dstPort, InetAddress localAddress, int localPort) throws UnknownHostException, IOException | |
Socket (InetAddress dstAddress, int dstPort) throws IOException | |
Socket (InetAddress dstAddress, int dstPort, InetAddress localAddress, int localPort) throws IOException | |
synchronized void | close () throws IOException |
InetAddress | getInetAddress () |
InputStream | getInputStream () throws IOException |
boolean | getKeepAlive () throws SocketException |
InetAddress | getLocalAddress () |
int | getLocalPort () |
OutputStream | getOutputStream () throws IOException |
int | getPort () |
int | getSoLinger () throws SocketException |
synchronized int | getReceiveBufferSize () throws SocketException |
synchronized int | getSendBufferSize () throws SocketException |
synchronized int | getSoTimeout () throws SocketException |
boolean | getTcpNoDelay () throws SocketException |
void | setKeepAlive (boolean keepAlive) throws SocketException |
synchronized void | setSendBufferSize (int size) throws SocketException |
synchronized void | setReceiveBufferSize (int size) throws SocketException |
void | setSoLinger (boolean on, int timeout) throws SocketException |
synchronized void | setSoTimeout (int timeout) throws SocketException |
void | setTcpNoDelay (boolean on) throws SocketException |
String | toString () |
void | shutdownInput () throws IOException |
void | shutdownOutput () throws IOException |
SocketAddress | getLocalSocketAddress () |
SocketAddress | getRemoteSocketAddress () |
boolean | isBound () |
boolean | isConnected () |
boolean | isClosed () |
void | bind (SocketAddress localAddr) throws IOException |
void | connect (SocketAddress remoteAddr) throws IOException |
void | connect (SocketAddress remoteAddr, int timeout) throws IOException |
boolean | isInputShutdown () |
boolean | isOutputShutdown () |
void | setReuseAddress (boolean reuse) throws SocketException |
boolean | getReuseAddress () throws SocketException |
void | setOOBInline (boolean oobinline) throws SocketException |
boolean | getOOBInline () throws SocketException |
void | setTrafficClass (int value) throws SocketException |
int | getTrafficClass () throws SocketException |
void | setPerformancePreferences (int connectionTime, int latency, int bandwidth) |
Protected Member Functions | |
Socket (SocketImpl impl) throws SocketException | |
Provides a client-side TCP socket.
|
inline |
Creates a new unconnected socket. When a SocketImplFactory is defined it creates the internal socket implementation, otherwise the default socket implementation will be used for this socket.
|
inline |
Creates a new streaming socket connected to the target host specified by the parameters
and
. The socket is bound to any available port on the local host.
This implementation tries each IP address for the given hostname (in RFC 3484 order) until it either connects successfully or it exhausts the set.
dstName | the target host name or IP address to connect to. |
dstPort | the port on the target host to connect to. |
UnknownHostException | if the host name could not be resolved into an IP address. |
IOException | if an error occurs while creating the socket. |
|
inline |
Creates a new streaming socket connected to the target host specified by the parameters
and
. On the local endpoint the socket is bound to the given address
on port
. If
is
a loopback address is used to connect to.
This implementation tries each IP address for the given hostname (in RFC 3484 order) until it either connects successfully or it exhausts the set.
dstName | the target host name or IP address to connect to. |
dstPort | the port on the target host to connect to. |
localAddress | the address on the local host to bind to. |
localPort | the port on the local host to bind to. |
UnknownHostException | if the host name could not be resolved into an IP address. |
IOException | if an error occurs while creating the socket. |
|
inline |
Creates a new streaming socket connected to the target host specified by the parameters
and
. The socket is bound to any available port on the local host.
dstAddress | the target host address to connect to. |
dstPort | the port on the target host to connect to. |
IOException | if an error occurs while creating the socket. |
|
inline |
Creates a new streaming socket connected to the target host specified by the parameters
and
. On the local endpoint the socket is bound to the given address
on port
.
dstAddress | the target host address to connect to. |
dstPort | the port on the target host to connect to. |
localAddress | the address on the local host to bind to. |
localPort | the port on the local host to bind to. |
IOException | if an error occurs while creating the socket. |
|
inlineprotected |
Creates an unconnected socket with the given socket implementation.
impl | the socket implementation to be used. |
SocketException | if an error occurs while creating the socket. |
|
inline |
Binds this socket to the given local host address and port specified by the SocketAddress
. If
is set to
, this socket will be bound to an available local address on any free port.
localAddr | the specific address and port on the local machine to bind to. |
IllegalArgumentException | if the given SocketAddress is invalid or not supported. |
IOException | if the socket is already bound or an error occurs while binding. |
|
inline |
Closes the socket. It is not possible to reconnect or rebind to this socket thereafter which means a new socket instance has to be created.
IOException | if an error occurs while closing the socket. |
|
inline |
Connects this socket to the given remote host address and port specified by the SocketAddress
.
remoteAddr | the address and port of the remote host to connect to. |
IllegalArgumentException | if the given SocketAddress is invalid or not supported. |
IOException | if the socket is already connected or an error occurs while connecting. |
|
inline |
Connects this socket to the given remote host address and port specified by the SocketAddress
with the specified timeout. The connecting method will block until the connection is established or an error occurred.
remoteAddr | the address and port of the remote host to connect to. |
timeout | the timeout value in milliseconds or 0 |
IllegalArgumentException | if the given SocketAddress is invalid or not supported or the timeout value is negative. |
IOException | if the socket is already connected or an error occurs while connecting. |
|
inline |
Returns the IP address of the target host this socket is connected to, or null if this socket is not yet connected.
|
inline |
Returns an input stream to read data from this socket.
IOException | if an error occurs while creating the input stream or the socket is in an invalid state. |
|
inline |
Returns this socket's SocketOptions#SO_KEEPALIVE setting.
|
inline |
Returns the local IP address this socket is bound to, or
if the socket is unbound.
|
inline |
Returns the local port this socket is bound to, or -1 if the socket is unbound.
|
inline |
Returns the local address and port of this socket as a SocketAddress or null if the socket is unbound. This is useful on multihomed hosts.
|
inline |
Returns this socket's SocketOptions#SO_OOBINLINE setting.
|
inline |
Returns an output stream to write data into this socket.
IOException | if an error occurs while creating the output stream or the socket is in an invalid state. |
|
inline |
Returns the port number of the target host this socket is connected to, or 0 if this socket is not yet connected.
|
inline |
Returns this socket's receive buffer size.
|
inline |
Returns the remote address and port of this socket as a
or null if the socket is not connected.
|
inline |
Returns this socket's SocketOptions#SO_REUSEADDR setting.
|
inline |
Returns this socket's send buffer size.
|
inline |
|
inline |
Returns this socket's receive timeout.
|
inline |
Returns this socket's
setting.
|
inline |
Returns this socket's {
|
inline |
Returns whether this socket is bound to a local address and port.
|
inline |
Returns whether this socket is closed.
|
inline |
Returns whether this socket is connected to a remote host.
|
inline |
Returns whether the incoming channel of the socket has already been closed.
|
inline |
Returns whether the outgoing channel of the socket has already been closed.
|
inline |
Sets this socket's SocketOptions#SO_KEEPALIVE option.
|
inline |
Sets this socket's SocketOptions#SO_OOBINLINE option.
|
inline |
Sets performance preferences for connectionTime, latency and bandwidth.
This method does currently nothing.
connectionTime | the value representing the importance of a short connecting time. |
latency | the value representing the importance of low latency. |
bandwidth | the value representing the importance of high bandwidth. |
|
inline |
Sets this socket's receive buffer size.
|
inline |
Sets this socket's SocketOptions#SO_REUSEADDR option.
|
inline |
Sets this socket's send buffer size.
|
inline |
|
inline |
Sets this socket's read timeout in milliseconds. Use 0 for no timeout. To take effect, this option must be set before the blocking method was called.
|
inline |
Sets this socket's SocketOptions#TCP_NODELAY option.
|
inline |
Sets this socket's SocketOptions#IP_TOS value for every packet sent by this socket.
|
inline |
Closes the input stream of this socket. Any further data sent to this socket will be discarded. Reading from this socket after this method has been called will return the value
.
IOException | if an error occurs while closing the socket input stream. |
SocketException | if the input stream is already closed. |
|
inline |
Closes the output stream of this socket. All buffered data will be sent followed by the termination sequence. Writing to the closed output stream will cause an
.
IOException | if an error occurs while closing the socket output stream. |
SocketException | if the output stream is already closed. |
|
inline |
Returns a
containing a concise, human-readable description of the socket.