| Modifier and Type | Field and Description |
|---|---|
| private final SocketChannelImpl | |
| private volatile int |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| public void | |
| public void | connect(SocketAddress remote, int timeout)
Overrides java. Connects this socket to the server with a specified timeout value. |
| pack-priv static Socket | |
| private boolean | |
| public SocketChannel | getChannel()
Overrides java. Returns the unique |
| public InetAddress | getInetAddress()
Overrides java. Returns the address to which the socket is connected. |
| public InputStream | |
| private int | |
| public boolean | |
| public InetAddress | getLocalAddress()
Overrides java. Gets the local address to which the socket is bound. |
| public int | getLocalPort()
Overrides java. Returns the local port number to which this socket is bound. |
| public SocketAddress | getLocalSocketAddress()
Overrides java. Returns the address of the endpoint this socket is bound to. |
| public boolean | |
| public <T> T | getOption(SocketOption<T> name)
Overrides java. Returns the value of a socket option. |
| public OutputStream | getOutputStream()
Overrides java. Returns an output stream for this socket. |
| public int | getPort()
Overrides java. Returns the remote port number to which this socket is connected. |
| public int | getReceiveBufferSize()
Overrides java. Gets the value of the |
| public SocketAddress | getRemoteSocketAddress()
Overrides java. Returns the address of the endpoint this socket is connected to, or
|
| public boolean | |
| public int | getSendBufferSize()
Overrides java. Get value of the |
| public int | |
| public int | |
| public boolean | |
| public int | getTrafficClass()
Overrides java. Gets traffic class or type-of-service in the IP header for packets sent from this Socket
As the underlying network implementation may ignore the
traffic class or type-of-service set using |
| public boolean | |
| public boolean | |
| public boolean | |
| public boolean | isInputShutdown()
Overrides java. Returns |
| public boolean | isOutputShutdown()
Overrides java. Returns |
| private InetSocketAddress | |
| private InetSocketAddress | |
| public void | sendUrgentData(int data)
Overrides java. Send one byte of urgent data on the socket. |
| private void | |
| private void | |
| public void | |
| public void | setOOBInline(boolean on)
Overrides java. Enable/disable |
| public <T> Socket | setOption(SocketOption<T> name, T value)
Overrides java. Sets the value of a socket option. |
| public void | setReceiveBufferSize(int size)
Overrides java. Sets the |
| public void | setReuseAddress(boolean on)
Overrides java. Enable/disable the |
| public void | setSendBufferSize(int size)
Overrides java. Sets the |
| public void | setSoLinger(boolean on, int linger)
Overrides java. Enable/disable |
| public void | setSoTimeout(int timeout)
Overrides java. Enable/disable |
| public void | setTcpNoDelay(boolean on)
Overrides java. Enable/disable |
| public void | setTrafficClass(int tc)
Overrides java. Sets traffic class or type-of-service octet in the IP header for packets sent from this Socket. |
| public void | shutdownInput()
Overrides java. Shutdown the connection for reading without closing the socket. |
| public void | shutdownOutput()
Overrides java. Shutdown the connection for writing without closing the socket. |
| public Set | supportedOptions()
Overrides java. Returns a set of the socket options supported by this socket. |
| public String |
| sc | back to summary |
|---|---|
| private final SocketChannelImpl sc | |
| timeout | back to summary |
|---|---|
| private volatile int timeout | |
| SocketAdaptor | back to summary |
|---|---|
| private SocketAdaptor(SocketChannelImpl sc) throws SocketException | |
| bind | back to summary |
|---|---|
| public void bind(SocketAddress local) throws IOException Overrides java. Doc from java. Binds the socket to a local address.
If the address is
| |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides java. Implements java. Doc from java. Closes this socket.
Any thread currently blocked in an I/O operation upon this socket
will throw a Once a socket has been closed, it is not available for further networking use (i.e. can't be reconnected or rebound) and several of the methods defined by this class will throw an exception if invoked on the closed socket. A new socket needs to be created. Closing this socket will also close the socket's
If this socket has an associated channel then the channel is closed as well.
| |
| connect | back to summary |
|---|---|
| public void connect(SocketAddress remote) throws IOException Overrides java. Doc from java. Connects this socket to the server. If the connection cannot be established, then the socket is closed,
and an This method is interruptible in the following circumstances:
| |
| connect | back to summary |
|---|---|
| public void connect(SocketAddress remote, int timeout) throws IOException Overrides java. Doc from java. Connects this socket to the server with a specified timeout value. A timeout of zero is interpreted as an infinite timeout. The connection will then block until established or an error occurs. If the connection cannot be established, or the timeout expires
before the connection is established, then the socket is closed, and an
This method is interruptible in the following circumstances:
| |
| create | back to summary |
|---|---|
| pack-priv static Socket create(SocketChannelImpl sc) | |
| getBooleanOption | back to summary |
|---|---|
| private boolean getBooleanOption(SocketOption<Boolean> name) throws SocketException | |
| getChannel | back to summary |
|---|---|
| public SocketChannel getChannel() Overrides java. Doc from java. Returns the unique A socket will have a channel if, and only if, the channel itself was
created via the
| |
| getInetAddress | back to summary |
|---|---|
| public InetAddress getInetAddress() Overrides java. Doc from java. Returns the address to which the socket is connected.
If the socket was connected prior to being
| |
| getInputStream | back to summary |
|---|---|
| public InputStream getInputStream() throws IOException Overrides java. Doc from java. Returns an input stream for this socket. If this socket has an associated channel then the resulting input
stream delegates all of its operations to the channel. If the channel
is in non-blocking mode then the input stream's Reading from the input stream is interruptible in the following circumstances:
Under abnormal conditions the underlying connection may be broken by the remote host or the network software (for example a connection reset in the case of TCP connections). When a broken connection is detected by the network software the following applies to the returned input stream :-
Closing the returned
| |
| getIntOption | back to summary |
|---|---|
| private int getIntOption(SocketOption<Integer> name) throws SocketException | |
| getKeepAlive | back to summary |
|---|---|
| public boolean getKeepAlive() throws SocketException Overrides java. Doc from java. Tests if
| |
| getLocalAddress | back to summary |
|---|---|
| public InetAddress getLocalAddress() Overrides java. Doc from java. Gets the local address to which the socket is bound.
| |
| getLocalPort | back to summary |
|---|---|
| public int getLocalPort() Overrides java. Doc from java. Returns the local port number to which this socket is bound.
If the socket was bound prior to being
| |
| getLocalSocketAddress | back to summary |
|---|---|
| public SocketAddress getLocalSocketAddress() Overrides java. Doc from java. Returns the address of the endpoint this socket is bound to.
If a socket bound to an endpoint represented by an
| |
| getOOBInline | back to summary |
|---|---|
| public boolean getOOBInline() throws SocketException Overrides java. Doc from java. Tests if
| |
| getOption | back to summary |
|---|---|
| public <T> T getOption(SocketOption<T> name) throws IOException Overrides java. Doc from java. Returns the value of a socket option.
| |
| getOutputStream | back to summary |
|---|---|
| public OutputStream getOutputStream() throws IOException Overrides java. Doc from java. Returns an output stream for this socket. If this socket has an associated channel then the resulting output
stream delegates all of its operations to the channel. If the channel
is in non-blocking mode then the output stream's Writing to the output stream is interruptible in the following circumstances:
Closing the returned
| |
| getPort | back to summary |
|---|---|
| public int getPort() Overrides java. Doc from java. Returns the remote port number to which this socket is connected.
If the socket was connected prior to being
| |
| getReceiveBufferSize | back to summary |
|---|---|
| public int getReceiveBufferSize() throws SocketException Overrides java. Doc from java. Gets the value of the
| |
| getRemoteSocketAddress | back to summary |
|---|---|
| public SocketAddress getRemoteSocketAddress() Overrides java. Doc from java. Returns the address of the endpoint this socket is connected to, or
If the socket was connected prior to being
| |
| getReuseAddress | back to summary |
|---|---|
| public boolean getReuseAddress() throws SocketException Overrides java. Doc from java. Tests if
| |
| getSendBufferSize | back to summary |
|---|---|
| public int getSendBufferSize() throws SocketException Overrides java. Doc from java. Get value of the
| |
| getSoLinger | back to summary |
|---|---|
| public int getSoLinger() throws SocketException Overrides java. Doc from java. Returns setting for
| |
| getSoTimeout | back to summary |
|---|---|
| public int getSoTimeout() throws SocketException Overrides java. Doc from java. Returns setting for
| |
| getTcpNoDelay | back to summary |
|---|---|
| public boolean getTcpNoDelay() throws SocketException Overrides java. Doc from java. Tests if
| |
| getTrafficClass | back to summary |
|---|---|
| public int getTrafficClass() throws SocketException Overrides java. Doc from java. Gets traffic class or type-of-service in the IP header for packets sent from this Socket
As the underlying network implementation may ignore the
traffic class or type-of-service set using
| |
| isBound | back to summary |
|---|---|
| public boolean isBound() Overrides java. Doc from java. Returns the binding state of the socket.
Closing a socket doesn't clear its binding state, which means
this method will return
| |
| isClosed | back to summary |
|---|---|
| public boolean isClosed() Overrides java. Doc from java. Returns the closed state of the socket.
| |
| isConnected | back to summary |
|---|---|
| public boolean isConnected() Overrides java. Doc from java. Returns the connection state of the socket.
Closing a socket doesn't clear its connection state, which means
this method will return
| |
| isInputShutdown | back to summary |
|---|---|
| public boolean isInputShutdown() Overrides java. Doc from java. Returns
| |
| isOutputShutdown | back to summary |
|---|---|
| public boolean isOutputShutdown() Overrides java. Doc from java. Returns
| |
| localAddress | back to summary |
|---|---|
| private InetSocketAddress localAddress() | |
| remoteAddress | back to summary |
|---|---|
| private InetSocketAddress remoteAddress() | |
| sendUrgentData | back to summary |
|---|---|
| public void sendUrgentData(int data) throws IOException Overrides java. Doc from java. Send one byte of urgent data on the socket. The byte to be sent is the lowest eight bits of the data parameter. The urgent byte is sent after any preceding writes to the socket OutputStream and before any future writes to the OutputStream.
| |
| setBooleanOption | back to summary |
|---|---|
| private void setBooleanOption(SocketOption<Boolean> name, boolean value) throws SocketException | |
| setIntOption | back to summary |
|---|---|
| private void setIntOption(SocketOption<Integer> name, int value) throws SocketException | |
| setKeepAlive | back to summary |
|---|---|
| public void setKeepAlive(boolean on) throws SocketException Overrides java. Doc from java. Enable/disable
| |
| setOOBInline | back to summary |
|---|---|
| public void setOOBInline(boolean on) throws SocketException Overrides java. Doc from java. Enable/disable Note, only limited support is provided for handling incoming urgent data. In particular, no notification of incoming urgent data is provided and there is no capability to distinguish between normal data and urgent data unless provided by a higher level protocol.
| |
| setOption | back to summary |
|---|---|
| public <T> Socket setOption(SocketOption<T> name, T value) throws IOException Overrides java. Doc from java. Sets the value of a socket option.
| |
| setReceiveBufferSize | back to summary |
|---|---|
| public void setReceiveBufferSize(int size) throws SocketException Overrides java. Doc from java. Sets the Increasing the receive buffer size can increase the performance of network I/O for high-volume connection, while decreasing it can help reduce the backlog of incoming data. Because The value of
| |
| setReuseAddress | back to summary |
|---|---|
| public void setReuseAddress(boolean on) throws SocketException Overrides java. Doc from java. Enable/disable the
When a TCP connection is closed the connection may remain
in a timeout state for a period of time after the connection
is closed (typically known as the
Enabling
When a
The behaviour when
| |
| setSendBufferSize | back to summary |
|---|---|
| public void setSendBufferSize(int size) throws SocketException Overrides java. Doc from java. Sets the Because
| |
| setSoLinger | back to summary |
|---|---|
| public void setSoLinger(boolean on, int linger) throws SocketException Overrides java. Doc from java. Enable/disable
| |
| setSoTimeout | back to summary |
|---|---|
| public void setSoTimeout(int timeout) throws SocketException Overrides java. Doc from java. Enable/disable
| |
| setTcpNoDelay | back to summary |
|---|---|
| public void setTcpNoDelay(boolean on) throws SocketException Overrides java. Doc from java. Enable/disable
| |
| setTrafficClass | back to summary |
|---|---|
| public void setTrafficClass(int tc) throws SocketException Overrides java. Doc from java. Sets traffic class or type-of-service octet in the IP header for packets sent from this Socket. As the underlying network implementation may ignore this value applications should consider it a hint. The tc must be in the range Notes For Internet Protocol v4 the value consists of an
Setting bits in the precedence field may result in a SocketException indicating that the operation is not permitted. As RFC 1122 section 4.2.4.2 indicates, a compliant TCP implementation should, but is not required to, let application change the TOS field during the lifetime of a connection. So whether the type-of-service field can be changed after the TCP connection has been established depends on the implementation in the underlying platform. Applications should not assume that they can change the TOS field after the connection.
For Internet Protocol v6
| |
| shutdownInput | back to summary |
|---|---|
| public void shutdownInput() throws IOException Overrides java. Doc from java. Shutdown the connection for reading without closing the socket.
If you read from a socket input stream
after invoking this method, the stream's
| |
| shutdownOutput | back to summary |
|---|---|
| public void shutdownOutput() throws IOException Overrides java. Doc from java. Shutdown the connection for writing without closing the socket.
If you write to a socket output stream
after invoking this method, the stream will throw an
| |
| supportedOptions | back to summary |
|---|---|
| public Set Overrides java. Doc from java. Returns a set of the socket options supported by this socket. This method will continue to return the set of options even after the socket has been closed.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Converts this socket to a
| |