APIdia Launch Partner
Top Fields Constructors Methods
sun.nio.ch

pack-priv Class SocketAdaptor

extends Socket
Class Inheritance
Imports
java.io.IOException, .InputStream, .OutputStream, java.net.InetAddress, .InetSocketAddress, .Socket, .SocketAddress, .SocketException, .SocketOption, .StandardSocketOptions, .UnknownHostException, java.nio.channels.SocketChannel, java.util.Set

Field Summary

Modifier and TypeField and Description
private final SocketChannelImpl
private volatile int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
bind(SocketAddress local)

Overrides java.net.Socket.bind.

Binds the socket to a local address.

public void
close()

Overrides java.net.Socket.close.

Implements java.io.Closeable.close.

Closes this socket.

public void
connect(SocketAddress remote)

Overrides java.net.Socket.connect.

Connects this socket to the server.

public void
connect(SocketAddress remote, int timeout)

Overrides java.net.Socket.connect.

Connects this socket to the server with a specified timeout value.

pack-priv static Socket
private boolean
public SocketChannel
getChannel()

Overrides java.net.Socket.getChannel.

Returns the unique SocketChannel object associated with this socket, if any.

public InetAddress
getInetAddress()

Overrides java.net.Socket.getInetAddress.

Returns the address to which the socket is connected.

public InputStream
getInputStream()

Overrides java.net.Socket.getInputStream.

Returns an input stream for this socket.

private int
public boolean
getKeepAlive()

Overrides java.net.Socket.getKeepAlive.

Tests if SO_KEEPALIVE is enabled.

public InetAddress
getLocalAddress()

Overrides java.net.Socket.getLocalAddress.

Gets the local address to which the socket is bound.

public int
getLocalPort()

Overrides java.net.Socket.getLocalPort.

Returns the local port number to which this socket is bound.

public SocketAddress
getLocalSocketAddress()

Overrides java.net.Socket.getLocalSocketAddress.

Returns the address of the endpoint this socket is bound to.

public boolean
getOOBInline()

Overrides java.net.Socket.getOOBInline.

Tests if SO_OOBINLINE is enabled.

public <T> T
getOption(SocketOption<T> name)

Overrides java.net.Socket.getOption.

Returns the value of a socket option.

public OutputStream
getOutputStream()

Overrides java.net.Socket.getOutputStream.

Returns an output stream for this socket.

public int
getPort()

Overrides java.net.Socket.getPort.

Returns the remote port number to which this socket is connected.

public int
getReceiveBufferSize()

Overrides java.net.Socket.getReceiveBufferSize.

Gets the value of the SO_RCVBUF option for this Socket, that is the buffer size used by the platform for input on this Socket.

public SocketAddress
getRemoteSocketAddress()

Overrides java.net.Socket.getRemoteSocketAddress.

Returns the address of the endpoint this socket is connected to, or null if it is unconnected.

public boolean
public int
getSendBufferSize()

Overrides java.net.Socket.getSendBufferSize.

Get value of the SO_SNDBUF option for this Socket, that is the buffer size used by the platform for output on this Socket.

public int
getSoLinger()

Overrides java.net.Socket.getSoLinger.

Returns setting for SO_LINGER.

public int
getSoTimeout()

Overrides java.net.Socket.getSoTimeout.

Returns setting for SO_TIMEOUT.

public boolean
getTcpNoDelay()

Overrides java.net.Socket.getTcpNoDelay.

Tests if TCP_NODELAY is enabled.

public int
getTrafficClass()

Overrides java.net.Socket.getTrafficClass.

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 setTrafficClass(int) this method may return a different value than was previously set using the setTrafficClass(int) method on this Socket.

public boolean
isBound()

Overrides java.net.Socket.isBound.

Returns the binding state of the socket.

public boolean
isClosed()

Overrides java.net.Socket.isClosed.

Returns the closed state of the socket.

public boolean
isConnected()

Overrides java.net.Socket.isConnected.

Returns the connection state of the socket.

public boolean
isInputShutdown()

Overrides java.net.Socket.isInputShutdown.

Returns true if the socket was shutdown for reading.

public boolean
isOutputShutdown()

Overrides java.net.Socket.isOutputShutdown.

Returns true if the socket was shutdown for writing.

private InetSocketAddress
private InetSocketAddress
public void
sendUrgentData(int data)

Overrides java.net.Socket.sendUrgentData.

Send one byte of urgent data on the socket.

private void
setBooleanOption(SocketOption<Boolean> name, boolean value)

private void
setIntOption(SocketOption<Integer> name, int value)

public void
setKeepAlive(boolean on)

Overrides java.net.Socket.setKeepAlive.

Enable/disable SO_KEEPALIVE.

public void
setOOBInline(boolean on)

Overrides java.net.Socket.setOOBInline.

Enable/disable SO_OOBINLINE (receipt of TCP urgent data) By default, this option is disabled and TCP urgent data received on a socket is silently discarded.

public <T> Socket
setOption(SocketOption<T> name, T value)

Overrides java.net.Socket.setOption.

Sets the value of a socket option.

public void
setReceiveBufferSize(int size)

Overrides java.net.Socket.setReceiveBufferSize.

Sets the SO_RCVBUF option to the specified value for this Socket.

public void
setReuseAddress(boolean on)

Overrides java.net.Socket.setReuseAddress.

Enable/disable the SO_REUSEADDR socket option.

public void
setSendBufferSize(int size)

Overrides java.net.Socket.setSendBufferSize.

Sets the SO_SNDBUF option to the specified value for this Socket.

public void
setSoLinger(boolean on, int linger)

Overrides java.net.Socket.setSoLinger.

Enable/disable SO_LINGER with the specified linger time in seconds.

public void
setSoTimeout(int timeout)

Overrides java.net.Socket.setSoTimeout.

Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds.

public void
setTcpNoDelay(boolean on)

Overrides java.net.Socket.setTcpNoDelay.

Enable/disable TCP_NODELAY (disable/enable Nagle's algorithm).

public void
setTrafficClass(int tc)

Overrides java.net.Socket.setTrafficClass.

Sets traffic class or type-of-service octet in the IP header for packets sent from this Socket.

public void
shutdownInput()

Overrides java.net.Socket.shutdownInput.

Shutdown the connection for reading without closing the socket.

public void
shutdownOutput()

Overrides java.net.Socket.shutdownOutput.

Shutdown the connection for writing without closing the socket.

public Set<SocketOption<?>>
supportedOptions()

Overrides java.net.Socket.supportedOptions.

Returns a set of the socket options supported by this socket.

public String
toString()

Overrides java.net.Socket.toString.

Converts this socket to a String.

Inherited from java.net.Socket:
setPerformancePreferencessetSocketImplFactory

Field Detail

scback to summary
private final SocketChannelImpl sc
timeoutback to summary
private volatile int timeout

Constructor Detail

SocketAdaptorback to summary
private SocketAdaptor(SocketChannelImpl sc) throws SocketException

Method Detail

bindback to summary
public void bind(SocketAddress local) throws IOException

Overrides java.net.Socket.bind.

Doc from java.net.Socket.bind.

Binds the socket to a local address.

If the address is null, then the system will pick up an ephemeral port and a valid local address to bind the socket.

Annotations
@Override
Exceptions
IOException:
if the bind operation fails, the socket is already bound or the socket is closed.
closeback to summary
public void close() throws IOException

Overrides java.net.Socket.close.

Implements java.io.Closeable.close.

Doc from java.net.Socket.close.

Closes this socket.

Any thread currently blocked in an I/O operation upon this socket will throw a SocketException.

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 InputStream and OutputStream.

If this socket has an associated channel then the channel is closed as well.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs when closing this socket.
connectback to summary
public void connect(SocketAddress remote) throws IOException

Overrides java.net.Socket.connect.

Doc from java.net.Socket.connect.

Connects this socket to the server.

If the connection cannot be established, then the socket is closed, and an IOException is thrown.

This method is interruptible in the following circumstances:

  1. The socket is associated with a SocketChannel. In that case, interrupting a thread establishing a connection will close the underlying channel and cause this method to throw ClosedByInterruptException with the thread's interrupted status set.
  2. The socket uses the system-default socket implementation and a virtual thread is establishing a connection. In that case, interrupting the virtual thread will cause it to wakeup and close the socket. This method will then throw SocketException with the thread's interrupted status set.
Annotations
@Override
Exceptions
IOException:
if an error occurs during the connection, the socket is already connected or the socket is closed
connectback to summary
public void connect(SocketAddress remote, int timeout) throws IOException

Overrides java.net.Socket.connect.

Doc from java.net.Socket.connect.

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 IOException is thrown.

This method is interruptible in the following circumstances:

  1. The socket is associated with a SocketChannel. In that case, interrupting a thread establishing a connection will close the underlying channel and cause this method to throw ClosedByInterruptException with the thread's interrupted status set.
  2. The socket uses the system-default socket implementation and a virtual thread is establishing a connection. In that case, interrupting the virtual thread will cause it to wakeup and close the socket. This method will then throw SocketException with the thread's interrupted status set.
Annotations
@Override
Exceptions
IOException:
if an error occurs during the connection, the socket is already connected or the socket is closed
createback to summary
pack-priv static Socket create(SocketChannelImpl sc)
getBooleanOptionback to summary
private boolean getBooleanOption(SocketOption<Boolean> name) throws SocketException
getChannelback to summary
public SocketChannel getChannel()

Overrides java.net.Socket.getChannel.

Doc from java.net.Socket.getChannel.

Returns the unique SocketChannel object associated with this socket, if any.

A socket will have a channel if, and only if, the channel itself was created via the SocketChannel.open or ServerSocketChannel.accept methods.

Annotations
@Override
getInetAddressback to summary
public InetAddress getInetAddress()

Overrides java.net.Socket.getInetAddress.

Doc from java.net.Socket.getInetAddress.

Returns the address to which the socket is connected.

If the socket was connected prior to being closed, then this method will continue to return the connected address after the socket is closed.

Annotations
@Override
getInputStreamback to summary
public InputStream getInputStream() throws IOException

Overrides java.net.Socket.getInputStream.

Doc from java.net.Socket.getInputStream.

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 read operations will throw an java.nio.channels.IllegalBlockingModeException.

Reading from the input stream is interruptible in the following circumstances:

  1. The socket is associated with a SocketChannel. In that case, interrupting a thread reading from the input stream will close the underlying channel and cause the read method to throw ClosedByInterruptException with the thread's interrupted status set.
  2. The socket uses the system-default socket implementation and a virtual thread is reading from the input stream. In that case, interrupting the virtual thread will cause it to wakeup and close the socket. The read method will then throw SocketException with the thread's interrupted status set.

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 :-

  • The network software may discard bytes that are buffered by the socket. Bytes that aren't discarded by the network software can be read using read.

  • If there are no bytes buffered on the socket, or all buffered bytes have been consumed by read, then all subsequent calls to read will throw an IOException.

  • If there are no bytes buffered on the socket, and the socket has not been closed using close, then available will return 0.

Closing the returned InputStream will close the associated socket.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs when creating the input stream, the socket is closed, the socket is not connected, or the socket input has been shutdown using shutdownInput()
getIntOptionback to summary
private int getIntOption(SocketOption<Integer> name) throws SocketException
getKeepAliveback to summary
public boolean getKeepAlive() throws SocketException

Overrides java.net.Socket.getKeepAlive.

Doc from java.net.Socket.getKeepAlive.

Tests if SO_KEEPALIVE is enabled.

Annotations
@Override
Exceptions
SocketException:
if there is an error in the underlying protocol, such as a TCP error, or the socket is closed.
getLocalAddressback to summary
public InetAddress getLocalAddress()

Overrides java.net.Socket.getLocalAddress.

Doc from java.net.Socket.getLocalAddress.

Gets the local address to which the socket is bound.

Annotations
@Override
getLocalPortback to summary
public int getLocalPort()

Overrides java.net.Socket.getLocalPort.

Doc from java.net.Socket.getLocalPort.

Returns the local port number to which this socket is bound.

If the socket was bound prior to being closed, then this method will continue to return the local port number after the socket is closed.

Annotations
@Override
getLocalSocketAddressback to summary
public SocketAddress getLocalSocketAddress()

Overrides java.net.Socket.getLocalSocketAddress.

Doc from java.net.Socket.getLocalSocketAddress.

Returns the address of the endpoint this socket is bound to.

If a socket bound to an endpoint represented by an InetSocketAddress is closed, then this method will continue to return an InetSocketAddress after the socket is closed. In that case the returned InetSocketAddress's address is the wildcard address and its port is the local port that it was bound to.

Annotations
@Override
getOOBInlineback to summary
public boolean getOOBInline() throws SocketException

Overrides java.net.Socket.getOOBInline.

Doc from java.net.Socket.getOOBInline.

Tests if SO_OOBINLINE is enabled.

Annotations
@Override
Exceptions
SocketException:
if there is an error in the underlying protocol, such as a TCP error, or the socket is closed.
getOptionback to summary
public <T> T getOption(SocketOption<T> name) throws IOException

Overrides java.net.Socket.getOption.

Doc from java.net.Socket.getOption.

Returns the value of a socket option.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs, or if the socket is closed.
getOutputStreamback to summary
public OutputStream getOutputStream() throws IOException

Overrides java.net.Socket.getOutputStream.

Doc from java.net.Socket.getOutputStream.

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 write operations will throw an java.nio.channels.IllegalBlockingModeException.

Writing to the output stream is interruptible in the following circumstances:

  1. The socket is associated with a SocketChannel. In that case, interrupting a thread writing to the output stream will close the underlying channel and cause the write method to throw ClosedByInterruptException with the thread's interrupted status set.
  2. The socket uses the system-default socket implementation and a virtual thread is writing to the output stream. In that case, interrupting the virtual thread will cause it to wakeup and close the socket. The write method will then throw SocketException with the thread's interrupted status set.

Closing the returned OutputStream will close the associated socket.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs when creating the output stream, the socket is not connected or the socket is closed.
getPortback to summary
public int getPort()

Overrides java.net.Socket.getPort.

Doc from java.net.Socket.getPort.

Returns the remote port number to which this socket is connected.

If the socket was connected prior to being closed, then this method will continue to return the connected port number after the socket is closed.

Annotations
@Override
getReceiveBufferSizeback to summary
public int getReceiveBufferSize() throws SocketException

Overrides java.net.Socket.getReceiveBufferSize.

Doc from java.net.Socket.getReceiveBufferSize.

Gets the value of the SO_RCVBUF option for this Socket, that is the buffer size used by the platform for input on this Socket.

Annotations
@Override
Exceptions
SocketException:
if there is an error in the underlying protocol, such as a TCP error, or the socket is closed.
getRemoteSocketAddressback to summary
public SocketAddress getRemoteSocketAddress()

Overrides java.net.Socket.getRemoteSocketAddress.

Doc from java.net.Socket.getRemoteSocketAddress.

Returns the address of the endpoint this socket is connected to, or null if it is unconnected.

If the socket was connected prior to being closed, then this method will continue to return the connected address after the socket is closed.

Annotations
@Override
getReuseAddressback to summary
public boolean getReuseAddress() throws SocketException

Overrides java.net.Socket.getReuseAddress.

Doc from java.net.Socket.getReuseAddress.

Tests if SO_REUSEADDR is enabled.

Annotations
@Override
Exceptions
SocketException:
if there is an error in the underlying protocol, such as a TCP error, or the socket is closed.
getSendBufferSizeback to summary
public int getSendBufferSize() throws SocketException

Overrides java.net.Socket.getSendBufferSize.

Doc from java.net.Socket.getSendBufferSize.

Get value of the SO_SNDBUF option for this Socket, that is the buffer size used by the platform for output on this Socket.

Annotations
@Override
Exceptions
SocketException:
if there is an error in the underlying protocol, such as a TCP error, or the socket is closed.
getSoLingerback to summary
public int getSoLinger() throws SocketException

Overrides java.net.Socket.getSoLinger.

Doc from java.net.Socket.getSoLinger.

Returns setting for SO_LINGER. -1 returns implies that the option is disabled. The setting only affects socket close.

Annotations
@Override
Exceptions
SocketException:
if there is an error in the underlying protocol, such as a TCP error, or the socket is closed.
getSoTimeoutback to summary
public int getSoTimeout() throws SocketException

Overrides java.net.Socket.getSoTimeout.

Doc from java.net.Socket.getSoTimeout.

Returns setting for SO_TIMEOUT. 0 returns implies that the option is disabled (i.e., timeout of infinity).

Annotations
@Override
Exceptions
SocketException:
if there is an error in the underlying protocol, such as a TCP error, or the socket is closed.
getTcpNoDelayback to summary
public boolean getTcpNoDelay() throws SocketException

Overrides java.net.Socket.getTcpNoDelay.

Doc from java.net.Socket.getTcpNoDelay.

Tests if TCP_NODELAY is enabled.

Annotations
@Override
Exceptions
SocketException:
if there is an error in the underlying protocol, such as a TCP error, or the socket is closed.
getTrafficClassback to summary
public int getTrafficClass() throws SocketException

Overrides java.net.Socket.getTrafficClass.

Doc from java.net.Socket.getTrafficClass.

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 setTrafficClass(int) this method may return a different value than was previously set using the setTrafficClass(int) method on this Socket.

Annotations
@Override
Exceptions
SocketException:
if there is an error obtaining the traffic class or type-of-service value, or the socket is closed.
isBoundback to summary
public boolean isBound()

Overrides java.net.Socket.isBound.

Doc from java.net.Socket.isBound.

Returns the binding state of the socket.

Closing a socket doesn't clear its binding state, which means this method will return true for a closed socket if it was successfully bound prior to being closed.

Annotations
@Override
isClosedback to summary
public boolean isClosed()

Overrides java.net.Socket.isClosed.

Doc from java.net.Socket.isClosed.

Returns the closed state of the socket.

Annotations
@Override
isConnectedback to summary
public boolean isConnected()

Overrides java.net.Socket.isConnected.

Doc from java.net.Socket.isConnected.

Returns the connection state of the socket.

Closing a socket doesn't clear its connection state, which means this method will return true for a closed socket if it was successfully connected prior to being closed.

Annotations
@Override
isInputShutdownback to summary
public boolean isInputShutdown()

Overrides java.net.Socket.isInputShutdown.

Doc from java.net.Socket.isInputShutdown.

Returns true if the socket was shutdown for reading.

Annotations
@Override
isOutputShutdownback to summary
public boolean isOutputShutdown()

Overrides java.net.Socket.isOutputShutdown.

Doc from java.net.Socket.isOutputShutdown.

Returns true if the socket was shutdown for writing.

Annotations
@Override
localAddressback to summary
private InetSocketAddress localAddress()
remoteAddressback to summary
private InetSocketAddress remoteAddress()
sendUrgentDataback to summary
public void sendUrgentData(int data) throws IOException

Overrides java.net.Socket.sendUrgentData.

Doc from java.net.Socket.sendUrgentData.

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.

Annotations
@Override
Exceptions
IOException:
if there is an error sending the data.
setBooleanOptionback to summary
private void setBooleanOption(SocketOption<Boolean> name, boolean value) throws SocketException
setIntOptionback to summary
private void setIntOption(SocketOption<Integer> name, int value) throws SocketException
setKeepAliveback to summary
public void setKeepAlive(boolean on) throws SocketException

Overrides java.net.Socket.setKeepAlive.

Doc from java.net.Socket.setKeepAlive.

Enable/disable SO_KEEPALIVE.

Annotations
@Override
Exceptions
SocketException:
if there is an error in the underlying protocol, such as a TCP error, or the socket is closed.
setOOBInlineback to summary
public void setOOBInline(boolean on) throws SocketException

Overrides java.net.Socket.setOOBInline.

Doc from java.net.Socket.setOOBInline.

Enable/disable SO_OOBINLINE (receipt of TCP urgent data) By default, this option is disabled and TCP urgent data received on a socket is silently discarded. If the user wishes to receive urgent data, then this option must be enabled. When enabled, urgent data is received inline with normal data.

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.

Annotations
@Override
Exceptions
SocketException:
if there is an error in the underlying protocol, such as a TCP error, or the socket is closed.
setOptionback to summary
public <T> Socket setOption(SocketOption<T> name, T value) throws IOException

Overrides java.net.Socket.setOption.

Doc from java.net.Socket.setOption.

Sets the value of a socket option.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs, or if the socket is closed.
setReceiveBufferSizeback to summary
public void setReceiveBufferSize(int size) throws SocketException

Overrides java.net.Socket.setReceiveBufferSize.

Doc from java.net.Socket.setReceiveBufferSize.

Sets the SO_RCVBUF option to the specified value for this Socket. The SO_RCVBUF option is used by the platform's networking code as a hint for the size to set the underlying network I/O buffers.

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 SO_RCVBUF is a hint, applications that want to verify what size the buffers were set to should call getReceiveBufferSize().

The value of SO_RCVBUF is also used to set the TCP receive window that is advertised to the remote peer. Generally, the window size can be modified at any time when a socket is connected. However, if a receive window larger than 64K is required then this must be requested before the socket is connected to the remote peer. There are two cases to be aware of:

  1. For sockets accepted from a ServerSocket, this must be done by calling ServerSocket#setReceiveBufferSize(int) before the ServerSocket is bound to a local address.
  2. For client sockets, setReceiveBufferSize() must be called before connecting the socket to its remote peer.
Annotations
@Override
Exceptions
SocketException:
if there is an error in the underlying protocol, such as a TCP error, or the socket is closed.
setReuseAddressback to summary
public void setReuseAddress(boolean on) throws SocketException

Overrides java.net.Socket.setReuseAddress.

Doc from java.net.Socket.setReuseAddress.

Enable/disable the SO_REUSEADDR socket option.

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 TIME_WAIT state or 2MSL wait state). For applications using a well known socket address or port it may not be possible to bind a socket to the required SocketAddress if there is a connection in the timeout state involving the socket address or port.

Enabling SO_REUSEADDR prior to binding the socket using bind(SocketAddress) allows the socket to be bound even though a previous connection is in a timeout state.

When a Socket is created the initial setting of SO_REUSEADDR is disabled.

The behaviour when SO_REUSEADDR is enabled or disabled after a socket is bound (See isBound()) is not defined.

Annotations
@Override
Exceptions
SocketException:
if an error occurs enabling or disabling the SO_REUSEADDR socket option, or the socket is closed.
setSendBufferSizeback to summary
public void setSendBufferSize(int size) throws SocketException

Overrides java.net.Socket.setSendBufferSize.

Doc from java.net.Socket.setSendBufferSize.

Sets the SO_SNDBUF option to the specified value for this Socket. The SO_SNDBUF option is used by the platform's networking code as a hint for the size to set the underlying network I/O buffers.

Because SO_SNDBUF is a hint, applications that want to verify what size the buffers were set to should call getSendBufferSize().

Annotations
@Override
Exceptions
SocketException:
if there is an error in the underlying protocol, such as a TCP error, or the socket is closed.
setSoLingerback to summary
public void setSoLinger(boolean on, int linger) throws SocketException

Overrides java.net.Socket.setSoLinger.

Doc from java.net.Socket.setSoLinger.

Enable/disable SO_LINGER with the specified linger time in seconds. The maximum timeout value is platform specific. The setting only affects socket close.

Annotations
@Override
Exceptions
SocketException:
if there is an error in the underlying protocol, such as a TCP error, or the socket is closed.
setSoTimeoutback to summary
public void setSoTimeout(int timeout) throws SocketException

Overrides java.net.Socket.setSoTimeout.

Doc from java.net.Socket.setSoTimeout.

Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds. With this option set to a positive timeout value, a read() call on the InputStream associated with this Socket will block for only this amount of time. If the timeout expires, a java.net.SocketTimeoutException is raised, though the Socket is still valid. A timeout of zero is interpreted as an infinite timeout. The option must be enabled prior to entering the blocking operation to have effect.

Annotations
@Override
Exceptions
SocketException:
if there is an error in the underlying protocol, such as a TCP error, or the socket is closed.
setTcpNoDelayback to summary
public void setTcpNoDelay(boolean on) throws SocketException

Overrides java.net.Socket.setTcpNoDelay.

Doc from java.net.Socket.setTcpNoDelay.

Enable/disable TCP_NODELAY (disable/enable Nagle's algorithm).

Annotations
@Override
Exceptions
SocketException:
if there is an error in the underlying protocol, such as a TCP error, or the socket is closed.
setTrafficClassback to summary
public void setTrafficClass(int tc) throws SocketException

Overrides java.net.Socket.setTrafficClass.

Doc from java.net.Socket.setTrafficClass.

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 0 <= tc <= 255 or an IllegalArgumentException will be thrown.

Notes

For Internet Protocol v4 the value consists of an integer, the least significant 8 bits of which represent the value of the TOS octet in IP packets sent by the socket. RFC 1349 defines the TOS values as follows:

  • IPTOS_LOWCOST (0x02)
  • IPTOS_RELIABILITY (0x04)
  • IPTOS_THROUGHPUT (0x08)
  • IPTOS_LOWDELAY (0x10)
The last low order bit is always ignored as this corresponds to the MBZ (must be zero) bit.

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 tc is the value that would be placed into the sin6_flowinfo field of the IP header.

Annotations
@Override
Exceptions
SocketException:
if there is an error setting the traffic class or type-of-service, or the socket is closed.
shutdownInputback to summary
public void shutdownInput() throws IOException

Overrides java.net.Socket.shutdownInput.

Doc from java.net.Socket.shutdownInput.

Shutdown the connection for reading without closing the socket.

If you read from a socket input stream after invoking this method, the stream's available method will return 0, and its read methods will return -1 (end of stream).

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs when shutting down this socket, the socket is not connected, the socket is already shutdown for reading, or the socket is closed.
shutdownOutputback to summary
public void shutdownOutput() throws IOException

Overrides java.net.Socket.shutdownOutput.

Doc from java.net.Socket.shutdownOutput.

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 IOException.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs when shutting down this socket, the socket is not connected, the socket is already shutdown for writing, or the socket is closed.
supportedOptionsback to summary
public Set<SocketOption<?>> supportedOptions()

Overrides java.net.Socket.supportedOptions.

Doc from java.net.Socket.supportedOptions.

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.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.net.Socket.toString.

Doc from java.net.Socket.toString.

Converts this socket to a String.

Annotations
@Override