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

public final Class NioSocketImpl

extends SocketImpl
implements PlatformSocketImpl
Class Inheritance
All Implemented Interfaces
sun.net.PlatformSocketImpl
Imports
java.io.FileDescriptor, .IOException, .InputStream, .InterruptedIOException, .OutputStream, .UncheckedIOException, java.lang.ref.Cleaner.Cleanable, java.net.InetAddress, .InetSocketAddress, .ProtocolFamily, .SocketAddress, .SocketException, .SocketImpl, .SocketOption, .SocketTimeoutException, .StandardProtocolFamily, .StandardSocketOptions, .UnknownHostException, java.nio.ByteBuffer, java.util.Collections, .HashSet, .Objects, .Set, java.util.concurrent.TimeUnit, java.util.concurrent.locks.ReentrantLock, jdk.internal.access.JavaIOFileDescriptorAccess, .SharedSecrets, jdk.internal.ref.CleanerFactory, sun.net.ConnectionResetException, .PlatformSocketImpl, sun.net.ext.ExtendedSocketOptions, jdk.internal.util.Exceptions

NIO based SocketImpl. The underlying socket used by this SocketImpl is initially configured blocking. If a connect, accept or read is attempted with a timeout, or a virtual thread invokes a blocking operation, then the socket is changed to non-blocking When in non-blocking mode, operations that don't complete immediately will poll the socket (or park when invoked on a virtual thread) and preserve the semantics of blocking operations.

Field Summary

Modifier and TypeField and Description
private Cleaner.Cleanable
private static volatile Set<SocketOption<?>>
private boolean
private volatile boolean
private volatile boolean
private boolean
private static final JavaIOFileDescriptorAccess
private static final NativeDispatcher
private volatile boolean
private boolean
private Thread
private final ReentrantLock
private final boolean
private static volatile Set<SocketOption<?>>
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private volatile int
private final Object
private volatile int
private final ReentrantLock
private Thread
Inherited from java.net.SocketImpl:
addressfdlocalportport

Constructor Summary

AccessConstructor and Description
public
NioSocketImpl(boolean
true if this is a SocketImpl for a ServerSocket
server
)

Creates an instance of this SocketImpl.

Method Summary

Modifier and TypeMethod and Description
protected void
accept(SocketImpl si)

Implements abstract java.net.SocketImpl.accept.

Accepts a new connection so that the given SocketImpl is connected to the peer.

private static SocketException
asSocketException(Exception e)

Creates a SocketException from the given exception.

protected int
available()

Implements abstract java.net.SocketImpl.available.

Returns the number of bytes that can be read from this socket without blocking.

private FileDescriptor
beginAccept()

Marks the beginning of an accept operation that might block.

private FileDescriptor
beginConnect(InetAddress address, int port)

Marks the beginning of a connect operation that might block.

private FileDescriptor
beginRead()

Marks the beginning of a read operation that might block.

private FileDescriptor
beginWrite()

Marks the beginning of a write operation that might block.

protected void
bind(InetAddress host, int port)

Implements abstract java.net.SocketImpl.bind.

Binds this socket to the specified local IP address and port number.

private boolean
booleanValue(Object value, String desc)

protected void
close()

Implements abstract java.net.SocketImpl.close.

Closes the socket.

private static Runnable
closerFor(FileDescriptor fd)

Returns an action to close the given file descriptor.

private void
configureNonBlockingIfNeeded(FileDescriptor fd, boolean timed)

Ensures that the socket is configured non-blocking invoked on a virtual thread or the operation has a timeout

protected void
connect(SocketAddress remote, int millis)

Implements abstract java.net.SocketImpl.connect.

Attempts to establish a connection to the given socket address with a timeout.

protected void
connect(String host, int port)

Implements abstract java.net.SocketImpl.connect.

Connects this socket to the specified port on the named host.

protected void
connect(InetAddress address, int port)

Implements abstract java.net.SocketImpl.connect.

Connects this socket to the specified port number on the specified host.

protected void
create(boolean
true for a streams socket
stream
)

Implements abstract java.net.SocketImpl.create.

Creates the socket.

private void
endAccept(boolean completed)

Marks the end of an accept operation that may have blocked.

private void
endConnect(FileDescriptor fd, boolean completed)

Marks the end of a connect operation that may have blocked.

private void
endRead(boolean completed)

Marks the end of a read operation that may have blocked.

private void
endWrite(boolean completed)

Marks the end of a write operation that may have blocked.

private void
ensureOpen()

Throws SocketException if the socket is not open.

private void
ensureOpenAndConnected()

Throws SocketException if the socket is not open and connected.

private static ProtocolFamily
family()

Returns the socket protocol family.

private static int
fdVal(FileDescriptor fd)

Return the file descriptor value.

protected InputStream
getInputStream()

Implements abstract java.net.SocketImpl.getInputStream.

Returns an input stream for this socket.

protected <T> T
getOption(SocketOption<T> opt)

Overrides java.net.SocketImpl.getOption.

Called to get a socket option.

public Object
getOption(int opt)

Implements java.net.SocketOptions.getOption.

Fetch the value of an option.

protected OutputStream
getOutputStream()

Implements abstract java.net.SocketImpl.getOutputStream.

Returns an output stream for this socket.

private int

Returns:

the number of bytes read or -1 at EOF
implRead
(byte[] b, int off, int len, long remainingNanos)

Reads bytes from the socket into the given byte array.

private int

Returns:

the number of bytes written
implWrite
(byte[] b, int off, int len)

Writes a sequence of bytes to the socket from the given byte array.

private int
intValue(Object value, String desc)

private boolean
isOpen()

Returns true if the socket is open.

protected void
listen(int backlog)

Implements abstract java.net.SocketImpl.listen.

Sets the maximum queue length for incoming connection indications (a request to connect) to the count argument.

private void
park(FileDescriptor fd, int event, long nanos)

Disables the current thread for scheduling purposes until the socket is ready for I/O or is asynchronously closed, for up to the specified waiting time.

private void
park(FileDescriptor fd, int event)

Disables the current thread for scheduling purposes until the socket is ready for I/O or is asynchronously closed.

private int

Returns:

the number of bytes read or -1 at EOF
read
(byte[] b, int off, int len)

Reads bytes from the socket into the given byte array.

protected void
sendUrgentData(int data)

Implements abstract java.net.SocketImpl.sendUrgentData.

Send one byte of urgent data on the socket.

protected <T> void
setOption(SocketOption<T> opt, T value)

Overrides java.net.SocketImpl.setOption.

Called to set a socket option.

public void
setOption(int opt, Object value)

Implements java.net.SocketOptions.setOption.

Enable/disable the option specified by optID.

protected void
shutdownInput()

Overrides java.net.SocketImpl.shutdownInput.

Places the input stream for this socket at "end of stream".

protected void
shutdownOutput()

Overrides java.net.SocketImpl.shutdownOutput.

Disables the output stream for this socket.

protected Set<SocketOption<?>>
supportedOptions()

Overrides java.net.SocketImpl.supportedOptions.

Returns a set of SocketOptions supported by this impl and by this impl's socket (Socket or ServerSocket)

protected boolean
supportsUrgentData()

Overrides java.net.SocketImpl.supportsUrgentData.

Returns whether or not this SocketImpl supports sending urgent data.

private int
timedAccept(FileDescriptor fd, FileDescriptor newfd, InetSocketAddress[] isaa, long nanos)

Accepts a new connection with a timeout.

private boolean
timedFinishConnect(FileDescriptor fd, long nanos)

Waits for a connection attempt to finish with a timeout

private int
timedRead(FileDescriptor fd, byte[] b, int off, int len, long nanos)

Reads bytes from the socket into the given byte array with a timeout.

private boolean
tryClose()

Closes the socket if there are no I/O operations in progress.

private void
tryFinishClose()

Invokes tryClose to attempt to close the socket.

private static long

Returns:

the remaining time in nanoseconds when the lock is acquired, zero or less if the lock was not acquired before the timeout expired
tryLock
(ReentrantLock lock, long timeout, TimeUnit unit)

Attempts to acquire the given lock within the given waiting time.

private int
tryRead(FileDescriptor fd, byte[] b, int off, int len)

Attempts to read bytes from the socket into the given byte array.

private int
tryWrite(FileDescriptor fd, byte[] b, int off, int len)

Attempts to write a sequence of bytes to the socket from the given byte array.

private void
write(byte[] b, int off, int len)

Writes a sequence of bytes to the socket from the given byte array.

Inherited from java.net.SocketImpl:
getFileDescriptorgetInetAddressgetLocalPortgetPortsetPerformancePreferencestoString

Field Detail

cleanerback to summary
private Cleaner.Cleanable cleaner
clientSocketOptionsback to summary
private static volatile Set<SocketOption<?>> clientSocketOptions
connectionResetback to summary
private boolean connectionReset
isInputClosedback to summary
private volatile boolean isInputClosed
isOutputClosedback to summary
private volatile boolean isOutputClosed
isReuseAddressback to summary
private boolean isReuseAddress
JIOFDAback to summary
private static final JavaIOFileDescriptorAccess JIOFDA
ndback to summary
private static final NativeDispatcher nd
nonBlockingback to summary
private volatile boolean nonBlocking
readEOFback to summary
private boolean readEOF
readerThreadback to summary
private Thread readerThread
readLockback to summary
private final ReentrantLock readLock
serverback to summary
private final boolean server
serverSocketOptionsback to summary
private static volatile Set<SocketOption<?>> serverSocketOptions
ST_CLOSEDback to summary
private static final int ST_CLOSED
ST_CLOSINGback to summary
private static final int ST_CLOSING
ST_CONNECTEDback to summary
private static final int ST_CONNECTED
ST_CONNECTINGback to summary
private static final int ST_CONNECTING
ST_NEWback to summary
private static final int ST_NEW
ST_UNCONNECTEDback to summary
private static final int ST_UNCONNECTED
stateback to summary
private volatile int state
stateLockback to summary
private final Object stateLock
timeoutback to summary
private volatile int timeout
writeLockback to summary
private final ReentrantLock writeLock
writerThreadback to summary
private Thread writerThread

Constructor Detail

NioSocketImplback to summary
public NioSocketImpl(boolean server)

Creates an instance of this SocketImpl.

Parameters
server:boolean

true if this is a SocketImpl for a ServerSocket

Method Detail

acceptback to summary
protected void accept(SocketImpl si) throws IOException

Implements abstract java.net.SocketImpl.accept.

Accepts a new connection so that the given SocketImpl is connected to the peer. The SocketImpl must be a newly created NioSocketImpl.

Annotations
@Override
Exceptions
IOException:

Doc from java.net.SocketImpl.accept.

if an I/O error occurs when accepting the connection.

asSocketExceptionback to summary
private static SocketException asSocketException(Exception e)

Creates a SocketException from the given exception.

availableback to summary
protected int available() throws IOException

Implements abstract java.net.SocketImpl.available.

Doc from java.net.SocketImpl.available.

Returns the number of bytes that can be read from this socket without blocking.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs when determining the number of bytes available.
beginAcceptback to summary
private FileDescriptor beginAccept() throws SocketException

Marks the beginning of an accept operation that might block.

Exceptions
SocketException:
if the socket is closed
beginConnectback to summary
private FileDescriptor beginConnect(InetAddress address, int port) throws IOException

Marks the beginning of a connect operation that might block.

Exceptions
SocketException:
if the socket is closed or already connected
beginReadback to summary
private FileDescriptor beginRead() throws SocketException

Marks the beginning of a read operation that might block.

Exceptions
SocketException:
if the socket is closed or not connected
beginWriteback to summary
private FileDescriptor beginWrite() throws SocketException

Marks the beginning of a write operation that might block.

Exceptions
SocketException:
if the socket is closed or not connected
bindback to summary
protected void bind(InetAddress host, int port) throws IOException

Implements abstract java.net.SocketImpl.bind.

Doc from java.net.SocketImpl.bind.

Binds this socket to the specified local IP address and port number.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs when binding this socket.
booleanValueback to summary
private boolean booleanValue(Object value, String desc) throws SocketException
closeback to summary
protected void close() throws IOException

Implements abstract java.net.SocketImpl.close.

Closes the socket. If there are I/O operations in progress then the socket is pre-closed and the threads are signalled. The socket will be closed when the last I/O operation aborts.

Annotations
@Override
Exceptions
IOException:

Doc from java.net.SocketImpl.close.

if an I/O error occurs when closing this socket.

closerForback to summary
private static Runnable closerFor(FileDescriptor fd)

Returns an action to close the given file descriptor.

configureNonBlockingIfNeededback to summary
private void configureNonBlockingIfNeeded(FileDescriptor fd, boolean timed) throws IOException

Ensures that the socket is configured non-blocking invoked on a virtual thread or the operation has a timeout

Exceptions
IOException:
if there is an I/O error changing the blocking mode
connectback to summary
protected void connect(SocketAddress remote, int millis) throws IOException

Implements abstract java.net.SocketImpl.connect.

Attempts to establish a connection to the given socket address with a timeout. Closes the socket if connection cannot be established.

Annotations
@Override
Exceptions
IOException:
if the address is not a resolved InetSocketAddress or the connection cannot be established
connectback to summary
protected void connect(String host, int port) throws IOException

Implements abstract java.net.SocketImpl.connect.

Doc from java.net.SocketImpl.connect.

Connects this socket to the specified port on the named host.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs when connecting to the remote host.
connectback to summary
protected void connect(InetAddress address, int port) throws IOException

Implements abstract java.net.SocketImpl.connect.

Doc from java.net.SocketImpl.connect.

Connects this socket to the specified port number on the specified host.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs when attempting a connection.
createback to summary
protected void create(boolean stream) throws IOException

Implements abstract java.net.SocketImpl.create.

Creates the socket.

Parameters
stream:boolean

true for a streams socket

Annotations
@Override
Exceptions
IOException:

Doc from java.net.SocketImpl.create.

if an I/O error occurs while creating the socket.

endAcceptback to summary
private void endAccept(boolean completed) throws SocketException

Marks the end of an accept operation that may have blocked.

Exceptions
SocketException:
is the socket is closed
endConnectback to summary
private void endConnect(FileDescriptor fd, boolean completed) throws IOException

Marks the end of a connect operation that may have blocked.

Exceptions
SocketException:
is the socket is closed
endReadback to summary
private void endRead(boolean completed) throws SocketException

Marks the end of a read operation that may have blocked.

Exceptions
SocketException:
is the socket is closed
endWriteback to summary
private void endWrite(boolean completed) throws SocketException

Marks the end of a write operation that may have blocked.

Exceptions
SocketException:
is the socket is closed
ensureOpenback to summary
private void ensureOpen() throws SocketException

Throws SocketException if the socket is not open.

ensureOpenAndConnectedback to summary
private void ensureOpenAndConnected() throws SocketException

Throws SocketException if the socket is not open and connected.

familyback to summary
private static ProtocolFamily family()

Returns the socket protocol family.

fdValback to summary
private static int fdVal(FileDescriptor fd)

Return the file descriptor value.

getInputStreamback to summary
protected InputStream getInputStream()

Implements abstract java.net.SocketImpl.getInputStream.

Doc from java.net.SocketImpl.getInputStream.

Returns an input stream for this socket.

Annotations
@Override
getOptionback to summary
protected <T> T getOption(SocketOption<T> opt) throws IOException

Overrides java.net.SocketImpl.getOption.

Doc from java.net.SocketImpl.getOption.

Called to get a socket option.

Annotations
@SuppressWarnings:unchecked
Exceptions
IOException:
if an I/O error occurs, or if the socket is closed
getOptionback to summary
public Object getOption(int opt) throws SocketException

Implements java.net.SocketOptions.getOption.

Doc from java.net.SocketOptions.getOption.

Fetch the value of an option. Binary options will return Boolean#TRUE if enabled, Boolean#FALSE if disabled, e.g.:

SocketImpl s; ... Boolean noDelay = (Boolean)(s.getOption(TCP_NODELAY)); if (noDelay.booleanValue()) { // true if TCP_NODELAY is enabled... ... }
SocketImpl s;
...
Boolean noDelay = (Boolean)(s.getOption(TCP_NODELAY));
if (noDelay.booleanValue()) {
    // true if TCP_NODELAY is enabled...
...
}

For options that take a particular type as a parameter, this method will return the parameter's value, else it will return Boolean#FALSE:

Object o = s.getOption(SO_LINGER); if (o instanceof Integer) { System.out.print("Linger time is " + ((Integer)o).intValue()); } else { // the true type of o is java.lang.Boolean.FALSE; }
Object o = s.getOption(SO_LINGER);
if (o instanceof Integer) {
    System.out.print("Linger time is " + ((Integer)o).intValue());
} else {
  // the true type of o is java.lang.Boolean.FALSE;
}
Annotations
@Override
Exceptions
SocketException:
if the socket is closed or if optID is unknown along the protocol stack
getOutputStreamback to summary
protected OutputStream getOutputStream()

Implements abstract java.net.SocketImpl.getOutputStream.

Doc from java.net.SocketImpl.getOutputStream.

Returns an output stream for this socket.

Annotations
@Override
implReadback to summary
private int implRead(byte[] b, int off, int len, long remainingNanos) throws IOException

Reads bytes from the socket into the given byte array.

Returns:int

the number of bytes read or -1 at EOF

Exceptions
SocketException:
if the socket is closed or a socket I/O error occurs
SocketTimeoutException:
if the read timeout elapses
implWriteback to summary
private int implWrite(byte[] b, int off, int len) throws IOException

Writes a sequence of bytes to the socket from the given byte array.

Returns:int

the number of bytes written

Exceptions
SocketException:
if the socket is closed or a socket I/O error occurs
intValueback to summary
private int intValue(Object value, String desc) throws SocketException
isOpenback to summary
private boolean isOpen()

Returns true if the socket is open.

listenback to summary
protected void listen(int backlog) throws IOException

Implements abstract java.net.SocketImpl.listen.

Doc from java.net.SocketImpl.listen.

Sets the maximum queue length for incoming connection indications (a request to connect) to the count argument. If a connection indication arrives when the queue is full, the connection is refused.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs when creating the queue.
parkback to summary
private void park(FileDescriptor fd, int event, long nanos) throws IOException

Disables the current thread for scheduling purposes until the socket is ready for I/O or is asynchronously closed, for up to the specified waiting time.

Exceptions
IOException:
if an I/O error occurs
parkback to summary
private void park(FileDescriptor fd, int event) throws IOException

Disables the current thread for scheduling purposes until the socket is ready for I/O or is asynchronously closed.

Exceptions
IOException:
if an I/O error occurs
readback to summary
private int read(byte[] b, int off, int len) throws IOException

Reads bytes from the socket into the given byte array.

Returns:int

the number of bytes read or -1 at EOF

Exceptions
IndexOutOfBoundsException:
if the bound checks fail
SocketException:
if the socket is closed or a socket I/O error occurs
SocketTimeoutException:
if the read timeout elapses
sendUrgentDataback to summary
protected void sendUrgentData(int data) throws IOException

Implements abstract java.net.SocketImpl.sendUrgentData.

Doc from java.net.SocketImpl.sendUrgentData.

Send one byte of urgent data on the socket. The byte to be sent is the low eight bits of the parameter

Annotations
@Override
Exceptions
IOException:
if there is an error sending the data.
setOptionback to summary
protected <T> void setOption(SocketOption<T> opt, T value) throws IOException

Overrides java.net.SocketImpl.setOption.

Doc from java.net.SocketImpl.setOption.

Called to set a socket option.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs, or if the socket is closed
setOptionback to summary
public void setOption(int opt, Object value) throws SocketException

Implements java.net.SocketOptions.setOption.

Doc from java.net.SocketOptions.setOption.

Enable/disable the option specified by optID. If the option is to be enabled, and it takes an option-specific "value", this is passed in value. The actual type of value is option-specific, and it is an error to pass something that isn't of the expected type:

SocketImpl s; ... s.setOption(SO_LINGER, Integer.valueOf(10)); // OK - set SO_LINGER w/ timeout of 10 sec. s.setOption(SO_LINGER, Double.valueOf(10)); // ERROR - expects java.lang.Integer
SocketImpl s;
...
s.setOption(SO_LINGER, Integer.valueOf(10));
   // OK - set SO_LINGER w/ timeout of 10 sec.
s.setOption(SO_LINGER, Double.valueOf(10));
   // ERROR - expects java.lang.Integer
If the requested option is binary, it can be set using this method by a Boolean:
s.setOption(TCP_NODELAY, Boolean.TRUE); // OK - enables TCP_NODELAY, a binary option
s.setOption(TCP_NODELAY, Boolean.TRUE);
   // OK - enables TCP_NODELAY, a binary option
Any option can be disabled using this method with a Boolean#FALSE:
s.setOption(TCP_NODELAY, Boolean.FALSE); // OK - disables TCP_NODELAY s.setOption(SO_LINGER, Boolean.FALSE); // OK - disables SO_LINGER
s.setOption(TCP_NODELAY, Boolean.FALSE);
   // OK - disables TCP_NODELAY
s.setOption(SO_LINGER, Boolean.FALSE);
   // OK - disables SO_LINGER
For an option that has a notion of on and off, and requires a non-boolean parameter, setting its value to anything other than Boolean#FALSE implicitly enables it.
Annotations
@Override
Exceptions
SocketException:
if the option is unrecognized, the socket is closed, or some low-level error occurred
shutdownInputback to summary
protected void shutdownInput() throws IOException

Overrides java.net.SocketImpl.shutdownInput.

Doc from java.net.SocketImpl.shutdownInput.

Places the input stream for this socket at "end of stream". Any data sent to this socket is acknowledged and then silently discarded. If you read from a socket input stream after invoking this method on the socket, 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.
shutdownOutputback to summary
protected void shutdownOutput() throws IOException

Overrides java.net.SocketImpl.shutdownOutput.

Doc from java.net.SocketImpl.shutdownOutput.

Disables the output stream for this socket. For a TCP socket, any previously written data will be sent followed by TCP's normal connection termination sequence. If you write to a socket output stream after invoking shutdownOutput() on the socket, the stream will throw an IOException.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs when shutting down this socket.
supportedOptionsback to summary
protected Set<SocketOption<?>> supportedOptions()

Overrides java.net.SocketImpl.supportedOptions.

Doc from java.net.SocketImpl.supportedOptions.

Returns a set of SocketOptions supported by this impl and by this impl's socket (Socket or ServerSocket)

Annotations
@Override
supportsUrgentDataback to summary
protected boolean supportsUrgentData()

Overrides java.net.SocketImpl.supportsUrgentData.

Doc from java.net.SocketImpl.supportsUrgentData.

Returns whether or not this SocketImpl supports sending urgent data. By default, false is returned unless the method is overridden in a sub-class

Annotations
@Override
timedAcceptback to summary
private int timedAccept(FileDescriptor fd, FileDescriptor newfd, InetSocketAddress[] isaa, long nanos) throws IOException

Accepts a new connection with a timeout.

Exceptions
SocketTimeoutException:
if the accept timeout elapses
timedFinishConnectback to summary
private boolean timedFinishConnect(FileDescriptor fd, long nanos) throws IOException

Waits for a connection attempt to finish with a timeout

Exceptions
SocketTimeoutException:
if the connect timeout elapses
timedReadback to summary
private int timedRead(FileDescriptor fd, byte[] b, int off, int len, long nanos) throws IOException

Reads bytes from the socket into the given byte array with a timeout.

Exceptions
SocketTimeoutException:
if the read timeout elapses
tryCloseback to summary
private boolean tryClose() throws IOException

Closes the socket if there are no I/O operations in progress.

tryFinishCloseback to summary
private void tryFinishClose()

Invokes tryClose to attempt to close the socket. This method is used for deferred closing by I/O operations.

tryLockback to summary
private static long tryLock(ReentrantLock lock, long timeout, TimeUnit unit)

Attempts to acquire the given lock within the given waiting time.

Returns:long

the remaining time in nanoseconds when the lock is acquired, zero or less if the lock was not acquired before the timeout expired

tryReadback to summary
private int tryRead(FileDescriptor fd, byte[] b, int off, int len) throws IOException

Attempts to read bytes from the socket into the given byte array.

tryWriteback to summary
private int tryWrite(FileDescriptor fd, byte[] b, int off, int len) throws IOException

Attempts to write a sequence of bytes to the socket from the given byte array.

writeback to summary
private void write(byte[] b, int off, int len) throws IOException

Writes a sequence of bytes to the socket from the given byte array.

Exceptions
SocketException:
if the socket is closed or a socket I/O error occurs