| Modifier and Type | Field and Description |
|---|---|
| private Cleaner. | |
| private static volatile Set | |
| 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 | |
| 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 |
| Access | Constructor and Description |
|---|---|
| public | NioSocketImpl(boolean
true if this is a SocketImpl for a ServerSocket server)Creates an instance of this SocketImpl. |
| Modifier and Type | Method and Description |
|---|---|
| protected void | accept(SocketImpl si)
Implements abstract java. Accepts a new connection so that the given SocketImpl is connected to the peer. |
| private static SocketException | |
| protected int | available()
Implements abstract java. Returns the number of bytes that can be read from this socket without blocking. |
| private FileDescriptor | |
| private FileDescriptor | beginConnect(InetAddress address, int port)
Marks the beginning of a connect operation that might block. |
| private FileDescriptor | |
| private FileDescriptor | |
| protected void | bind(InetAddress host, int port)
Implements abstract java. Binds this socket to the specified local IP address and port number. |
| private boolean | |
| protected void | |
| private static Runnable | |
| 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. Attempts to establish a connection to the given socket address with a timeout. |
| protected void | connect(String host, int port)
Implements abstract java. Connects this socket to the specified port on the named host. |
| protected void | connect(InetAddress address, int port)
Implements abstract java. Connects this socket to the specified port number on the specified host. |
| protected void | create(boolean
true for a streams socketImplements abstract java. Creates the socket. |
| private void | |
| private void | endConnect(FileDescriptor fd, boolean completed)
Marks the end of a connect operation that may have blocked. |
| private void | |
| private void | |
| private void | |
| private void | |
| private static ProtocolFamily | |
| private static int | |
| protected InputStream | getInputStream()
Implements abstract java. Returns an input stream for this socket. |
| protected <T> T | getOption(SocketOption<T> opt)
Overrides java. Called to get a socket option. |
| public Object | |
| protected OutputStream | getOutputStream()
Implements abstract java. Returns an output stream for this socket. |
| private int | Returns: the number of bytes read or -1 at EOFReads bytes from the socket into the given byte array. |
| private int | Returns: the number of bytes writtenWrites a sequence of bytes to the socket from the given byte array. |
| private int | |
| private boolean | |
| protected void | listen(int backlog)
Implements abstract java. Sets the maximum queue length for incoming connection indications
(a request to connect) to the |
| 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 EOFReads bytes from the socket into the given byte array. |
| protected void | sendUrgentData(int data)
Implements abstract java. Send one byte of urgent data on the socket. |
| protected <T> void | setOption(SocketOption<T> opt, T value)
Overrides java. Called to set a socket option. |
| public void | setOption(int opt, Object value)
Implements java. Enable/disable the option specified by |
| protected void | shutdownInput()
Overrides java. Places the input stream for this socket at "end of stream". |
| protected void | shutdownOutput()
Overrides java. Disables the output stream for this socket. |
| protected Set | supportedOptions()
Overrides java. Returns a set of SocketOptions supported by this impl and by this impl's socket (Socket or ServerSocket) |
| protected boolean | supportsUrgentData()
Overrides java. 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 | |
| private void | |
| 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 expiredAttempts 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. |
| cleaner | back to summary |
|---|---|
| private Cleaner. | |
| clientSocketOptions | back to summary |
|---|---|
| private static volatile Set<SocketOption<?>> clientSocketOptions | |
| connectionReset | back to summary |
|---|---|
| private boolean connectionReset | |
| isInputClosed | back to summary |
|---|---|
| private volatile boolean isInputClosed | |
| isOutputClosed | back to summary |
|---|---|
| private volatile boolean isOutputClosed | |
| isReuseAddress | back to summary |
|---|---|
| private boolean isReuseAddress | |
| JIOFDA | back to summary |
|---|---|
| private static final JavaIOFileDescriptorAccess JIOFDA | |
| nd | back to summary |
|---|---|
| private static final NativeDispatcher nd | |
| nonBlocking | back to summary |
|---|---|
| private volatile boolean nonBlocking | |
| readEOF | back to summary |
|---|---|
| private boolean readEOF | |
| readerThread | back to summary |
|---|---|
| private Thread readerThread | |
| readLock | back to summary |
|---|---|
| private final ReentrantLock readLock | |
| server | back to summary |
|---|---|
| private final boolean server | |
| serverSocketOptions | back to summary |
|---|---|
| private static volatile Set<SocketOption<?>> serverSocketOptions | |
| ST_CLOSED | back to summary |
|---|---|
| private static final int ST_CLOSED | |
| ST_CLOSING | back to summary |
|---|---|
| private static final int ST_CLOSING | |
| ST_CONNECTED | back to summary |
|---|---|
| private static final int ST_CONNECTED | |
| ST_CONNECTING | back to summary |
|---|---|
| private static final int ST_CONNECTING | |
| ST_NEW | back to summary |
|---|---|
| private static final int ST_NEW | |
| ST_UNCONNECTED | back to summary |
|---|---|
| private static final int ST_UNCONNECTED | |
| state | back to summary |
|---|---|
| private volatile int state | |
| stateLock | back to summary |
|---|---|
| private final Object stateLock | |
| timeout | back to summary |
|---|---|
| private volatile int timeout | |
| writeLock | back to summary |
|---|---|
| private final ReentrantLock writeLock | |
| writerThread | back to summary |
|---|---|
| private Thread writerThread | |
| NioSocketImpl | back to summary |
|---|---|
| public NioSocketImpl(boolean server) Creates an instance of this SocketImpl.
| |
| accept | back to summary |
|---|---|
| protected void accept(SocketImpl si) throws IOException Implements abstract java. Accepts a new connection so that the given SocketImpl is connected to the peer. The SocketImpl must be a newly created NioSocketImpl.
| |
| asSocketException | back to summary |
|---|---|
| private static SocketException asSocketException(Exception e) Creates a SocketException from the given exception. | |
| available | back to summary |
|---|---|
| protected int available() throws IOException Implements abstract java. Doc from java. Returns the number of bytes that can be read from this socket without blocking.
| |
| beginAccept | back to summary |
|---|---|
| private FileDescriptor beginAccept() throws SocketException Marks the beginning of an accept operation that might block.
| |
| beginConnect | back to summary |
|---|---|
| private FileDescriptor beginConnect(InetAddress address, int port) throws IOException Marks the beginning of a connect operation that might block.
| |
| beginRead | back to summary |
|---|---|
| private FileDescriptor beginRead() throws SocketException Marks the beginning of a read operation that might block.
| |
| beginWrite | back to summary |
|---|---|
| private FileDescriptor beginWrite() throws SocketException Marks the beginning of a write operation that might block.
| |
| bind | back to summary |
|---|---|
| protected void bind(InetAddress host, int port) throws IOException Implements abstract java. Doc from java. Binds this socket to the specified local IP address and port number.
| |
| booleanValue | back to summary |
|---|---|
| private boolean booleanValue(Object value, String desc) throws SocketException | |
| close | back to summary |
|---|---|
| protected void close() throws IOException Implements abstract java. 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.
| |
| closerFor | back to summary |
|---|---|
| private static Runnable closerFor(FileDescriptor fd) Returns an action to close the given file descriptor. | |
| configureNonBlockingIfNeeded | back 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
| |
| connect | back to summary |
|---|---|
| protected void connect(SocketAddress remote, int millis) throws IOException Implements abstract java. Attempts to establish a connection to the given socket address with a timeout. Closes the socket if connection cannot be established.
| |
| connect | back to summary |
|---|---|
| protected void connect(String host, int port) throws IOException Implements abstract java. Doc from java. Connects this socket to the specified port on the named host.
| |
| connect | back to summary |
|---|---|
| protected void connect(InetAddress address, int port) throws IOException Implements abstract java. Doc from java. Connects this socket to the specified port number on the specified host.
| |
| create | back to summary |
|---|---|
| protected void create(boolean stream) throws IOException Implements abstract java. Creates the socket.
| |
| endAccept | back to summary |
|---|---|
| private void endAccept(boolean completed) throws SocketException Marks the end of an accept operation that may have blocked.
| |
| endConnect | back to summary |
|---|---|
| private void endConnect(FileDescriptor fd, boolean completed) throws IOException Marks the end of a connect operation that may have blocked.
| |
| endRead | back to summary |
|---|---|
| private void endRead(boolean completed) throws SocketException Marks the end of a read operation that may have blocked.
| |
| endWrite | back to summary |
|---|---|
| private void endWrite(boolean completed) throws SocketException Marks the end of a write operation that may have blocked.
| |
| ensureOpen | back to summary |
|---|---|
| private void ensureOpen() throws SocketException Throws SocketException if the socket is not open. | |
| ensureOpenAndConnected | back to summary |
|---|---|
| private void ensureOpenAndConnected() throws SocketException Throws SocketException if the socket is not open and connected. | |
| family | back to summary |
|---|---|
| private static ProtocolFamily family() Returns the socket protocol family. | |
| fdVal | back to summary |
|---|---|
| private static int fdVal(FileDescriptor fd) Return the file descriptor value. | |
| getInputStream | back to summary |
|---|---|
| protected InputStream getInputStream() Implements abstract java. Doc from java. Returns an input stream for this socket.
| |
| getOption | back to summary |
|---|---|
| protected <T> T getOption(SocketOption<T> opt) throws IOException Overrides java. Doc from java. Called to get a socket option.
| |
| getOption | back to summary |
|---|---|
| public Object getOption(int opt) throws SocketException Implements java. Doc from java. Fetch the value of an option. Binary options will return 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 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; }
| |
| getOutputStream | back to summary |
|---|---|
| protected OutputStream getOutputStream() Implements abstract java. Doc from java. Returns an output stream for this socket.
| |
| implRead | back 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.
| |
| implWrite | back 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.
| |
| intValue | back to summary |
|---|---|
| private int intValue(Object value, String desc) throws SocketException | |
| isOpen | back to summary |
|---|---|
| private boolean isOpen() Returns true if the socket is open. | |
| listen | back to summary |
|---|---|
| protected void listen(int backlog) throws IOException Implements abstract java. Doc from java. Sets the maximum queue length for incoming connection indications
(a request to connect) to the
| |
| park | back 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.
| |
| park | back 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.
| |
| read | back to summary |
|---|---|
| private int read(byte[] b, int off, int len) throws IOException Reads bytes from the socket into the given byte array.
| |
| sendUrgentData | back to summary |
|---|---|
| protected void sendUrgentData(int data) throws IOException Implements abstract java. Doc from java. Send one byte of urgent data on the socket. The byte to be sent is the low eight bits of the parameter
| |
| setOption | back to summary |
|---|---|
| protected <T> void setOption(SocketOption<T> opt, T value) throws IOException Overrides java. Doc from java. Called to set a socket option.
| |
| setOption | back to summary |
|---|---|
| public void setOption(int opt, Object value) throws SocketException Implements java. Doc from java. Enable/disable the option specified by 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 Boolean:
s.setOption(TCP_NODELAY, Boolean.TRUE); // OK - enables TCP_NODELAY, a binary option Boolean#FALSE:
s.setOption(TCP_NODELAY, Boolean.FALSE); // OK - disables TCP_NODELAY s.setOption(SO_LINGER, Boolean.FALSE); // OK - disables SO_LINGER Boolean#FALSE implicitly enables it.
| |
| shutdownInput | back to summary |
|---|---|
| protected void shutdownInput() throws IOException Overrides java. Doc from java. 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
| |
| shutdownOutput | back to summary |
|---|---|
| protected void shutdownOutput() throws IOException Overrides java. Doc from java. 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.
| |
| supportedOptions | back to summary |
|---|---|
| protected Set Overrides java. Doc from java. Returns a set of SocketOptions supported by this impl and by this impl's socket (Socket or ServerSocket)
| |
| supportsUrgentData | back to summary |
|---|---|
| protected boolean supportsUrgentData() Overrides java. Doc from java. Returns whether or not this SocketImpl supports sending urgent data. By default, false is returned unless the method is overridden in a sub-class
| |
| timedAccept | back to summary |
|---|---|
| private int timedAccept(FileDescriptor fd, FileDescriptor newfd, InetSocketAddress[] isaa, long nanos) throws IOException Accepts a new connection with a timeout.
| |
| timedFinishConnect | back to summary |
|---|---|
| private boolean timedFinishConnect(FileDescriptor fd, long nanos) throws IOException Waits for a connection attempt to finish with a timeout
| |
| timedRead | back 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.
| |
| tryClose | back to summary |
|---|---|
| private boolean tryClose() throws IOException Closes the socket if there are no I/O operations in progress. | |
| tryFinishClose | back to summary |
|---|---|
| private void tryFinishClose() Invokes tryClose to attempt to close the socket. This method is used for deferred closing by I/O operations. | |
| tryLock | back to summary |
|---|---|
| private static long tryLock(ReentrantLock lock, long timeout, TimeUnit unit) Attempts to acquire the given lock within the given waiting time.
| |
| tryRead | back 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. | |
| tryWrite | back 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. | |
| write | back 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.
| |