java.nio.channels.Channel implementation that uses a native unix
socket
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| pack-priv static enum |
| Modifier and Type | Field and Description |
|---|---|
| private final BindHandler | |
| private UnixSocketAddress | |
| private UnixSocketAddress | |
| private UnixSocketChannel. | |
| private final ReadWriteLock |
| Access | Constructor and Description |
|---|---|
| pack-priv | |
| pack-priv | |
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public synchronized UnixSocketChannel | bind(SocketAddress
The address to bind the socket, or local)null to bind
the socket to an automatically assigned socket addressImplements abstract java. Implements java. |
| public boolean | |
| public boolean | connect(SocketAddress
The remote address to which this channel is to be connected remote)Implements abstract java. |
| public static final UnixSocketChannel | |
| private boolean | |
| public boolean | finishConnect()
Implements abstract java. |
| public static final UnixSocketChannel | Returns: the new UnixSocketChannel instancethe file descriptor to wrap fd)Create a UnixSocketChannel to wrap an existing file descriptor (presumably itself a UNIX socket). |
| public SocketAddress | getLocalAddress()
Implements abstract java. Implements java. |
| public final UnixSocketAddress | |
| public <T> T | getOption(SocketOption<T>
The socket option name)Implements java. |
| public SocketAddress | getRemoteAddress()
Implements abstract java. |
| public final UnixSocketAddress | |
| pack-priv boolean | |
| public boolean | isConnected()
Implements abstract java. |
| public boolean | isConnectionPending()
Implements abstract java. |
| private boolean | |
| public static final UnixSocketChannel | open()
Opens a socket channel for an Internet protocol socket.
|
| public static final UnixSocketChannel | |
| public static final UnixSocketChannel[] | |
| public int | read(ByteBuffer
The buffer into which bytes are to be transferred dst)Overrides jnr. Implements java. |
| public <T> SocketChannel | setOption(SocketOption<T>
The socket option name, T The value of the socket option. A value of value)null may be
a valid value for some socket options.Implements abstract java. Implements java. |
| public UnixSocket | socket()
Implements abstract java. |
| public final Set | supportedOptions()
Implements java. |
| public long | write(ByteBuffer[]
The buffers from which bytes are to be retrieved srcs, int The offset within the buffer array of the first buffer from
which bytes are to be retrieved; must be non-negative and no
larger than offset, int srcs.lengthThe maximum number of buffers to be accessed; must be
non-negative and no larger than
length)srcs.length - offsetOverrides jnr. Implements java. |
| public int | write(ByteBuffer
The buffer from which bytes are to be retrieved src)Overrides jnr. Implements java. |
| bindHandler | back to summary |
|---|---|
| private final BindHandler bindHandler | |
| localAddress | back to summary |
|---|---|
| private UnixSocketAddress localAddress | |
| remoteAddress | back to summary |
|---|---|
| private UnixSocketAddress remoteAddress | |
| state | back to summary |
|---|---|
| private UnixSocketChannel. | |
| stateLock | back to summary |
|---|---|
| private final ReadWriteLock stateLock | |
| UnixSocketChannel | back to summary |
|---|---|
| pack-priv UnixSocketChannel() throws IOException | |
| UnixSocketChannel | back to summary |
|---|---|
| pack-priv UnixSocketChannel(int fd) | |
| UnixSocketChannel | back to summary |
|---|---|
| pack-priv UnixSocketChannel(int fd, UnixSocketChannel. | |
| bind | back to summary |
|---|---|
| public synchronized UnixSocketChannel bind(SocketAddress local) throws IOException Implements abstract java. Implements java. Doc from java. Binds the channel's socket to a local address. This method is used to establish an association between the socket
and a local address. For Internet Protocol sockets, once an
association is established then the socket remains bound until the
channel is closed. If the
| |
| connect | back to summary |
|---|---|
| public boolean connect(UnixSocketAddress remote) throws IOException | |
| connect | back to summary |
|---|---|
| public boolean connect(SocketAddress remote) throws IOException Implements abstract java. Doc from java. Connects this channel's socket. If this channel is in non-blocking mode then an invocation of this
method initiates a non-blocking connection operation. If the connection
is established immediately, as can happen with a local connection, then
this method returns If this channel is in blocking mode then an invocation of this method will block until the connection is established or an I/O error occurs. For channels to Internet protocol sockets, this method performs
exactly the same security checks as the For channels to Unix Domain sockets, this method checks
This method may be invoked at any time. If a read or write operation upon this channel is invoked while an invocation of this method is in progress then that operation will first block until this invocation is complete. If a connection attempt is initiated but fails, that is, if an invocation of this method throws a checked exception, then the channel will be closed.
| |
| create | back to summary |
|---|---|
| public static final UnixSocketChannel create() throws IOException | |
| doConnect | back to summary |
|---|---|
| private boolean doConnect(SockAddrUnix remote) throws IOException | |
| finishConnect | back to summary |
|---|---|
| public boolean finishConnect() throws IOException Implements abstract java. Doc from java. Finishes the process of connecting a socket channel. A non-blocking connection operation is initiated by placing a socket
channel in non-blocking mode and then invoking its If this channel is already connected then this method will not block
and will immediately return This method may be invoked at any time. If a read or write operation upon this channel is invoked while an invocation of this method is in progress then that operation will first block until this invocation is complete. If a connection attempt fails, that is, if an invocation of this method throws a checked exception, then the channel will be closed.
| |
| fromFD | back to summary |
|---|---|
| public static final UnixSocketChannel fromFD(int fd) Create a UnixSocketChannel to wrap an existing file descriptor (presumably itself a UNIX socket).
| |
| getLocalAddress | back to summary |
|---|---|
| public SocketAddress getLocalAddress() throws IOException Implements abstract java. Implements java. Doc from java. Returns the socket address that this channel's socket is bound to. Where the channel is Where the channel is bound to a Unix Domain socket address, the socket
address is a
| |
| getLocalSocketAddress | back to summary |
|---|---|
| public final UnixSocketAddress getLocalSocketAddress() | |
| getOption | back to summary |
|---|---|
| public <T> T getOption(SocketOption<T> name) throws IOException Implements java. Doc from java. Returns the value of a socket option.
| |
| getRemoteAddress | back to summary |
|---|---|
| public SocketAddress getRemoteAddress() throws IOException Implements abstract java. Doc from java. Returns the remote address to which this channel's socket is connected. Where the channel's socket is bound and connected to an Internet
Protocol socket address then the return value is of type
Where the channel's socket is bound and connected to a Unix Domain
socket address, the returned address is a
| |
| getRemoteSocketAddress | back to summary |
|---|---|
| public final UnixSocketAddress getRemoteSocketAddress() | |
| isBound | back to summary |
|---|---|
| pack-priv boolean isBound() | |
| isConnected | back to summary |
|---|---|
| public boolean isConnected() Implements abstract java. Doc from java. Tells whether or not this channel's network socket is connected.
| |
| isConnectionPending | back to summary |
|---|---|
| public boolean isConnectionPending() Implements abstract java. Doc from java. Tells whether or not a connection operation is in progress on this channel.
| |
| isIdle | back to summary |
|---|---|
| private boolean isIdle() | |
| open | back to summary |
|---|---|
| public static final UnixSocketChannel open() throws IOException Hides java. Doc from java. Opens a socket channel for an Internet protocol socket. The new channel is created by invoking the
| |
| open | back to summary |
|---|---|
| public static final UnixSocketChannel open(UnixSocketAddress remote) throws IOException | |
| pair | back to summary |
|---|---|
| public static final UnixSocketChannel[] pair() throws IOException | |
| read | back to summary |
|---|---|
| public int read(ByteBuffer dst) throws IOException Overrides jnr. Implements java. Doc from java. Reads a sequence of bytes from this channel into the given buffer. An attempt is made to read up to r bytes from the channel,
where r is the number of bytes remaining in the buffer, that is,
Suppose that a byte sequence of length n is read, where
A read operation might not fill the buffer, and in fact it might not read any bytes at all. Whether or not it does so depends upon the nature and state of the channel. A socket channel in non-blocking mode, for example, cannot read any more bytes than are immediately available from the socket's input buffer; similarly, a file channel cannot read any more bytes than remain in the file. It is guaranteed, however, that if a channel is in blocking mode and there is at least one byte remaining in the buffer then this method will block until at least one byte is read. This method may be invoked at any time. If another thread has already initiated a read operation upon this channel, however, then an invocation of this method will block until the first operation is complete.
| |
| setOption | back to summary |
|---|---|
| public <T> SocketChannel setOption(SocketOption<T> name, T value) throws IOException Implements abstract java. Implements java. Doc from java. Sets the value of a socket option.
| |
| socket | back to summary |
|---|---|
| public UnixSocket socket() Implements abstract java. Doc from java. Retrieves a socket associated with this channel.
| |
| supportedOptions | back to summary |
|---|---|
| public final Set Implements java. Doc from java. Returns a set of the socket options supported by this channel. This method will continue to return the set of options even after the channel has been closed.
| |
| write | back to summary |
|---|---|
| public long write(ByteBuffer[] srcs, int offset, int length) throws IOException Overrides jnr. Implements java. Doc from java. Writes a sequence of bytes to this channel from a subsequence of the given buffers. An attempt is made to write up to r bytes to this channel, where r is the total number of bytes remaining in the specified subsequence of the given buffer array, that is, srcs[offset].remaining() + srcs[offset+1].remaining() + ... + srcs[offset+length-1].remaining() Suppose that a byte sequence of length n is written, where
Unless otherwise specified, a write operation will return only after writing all of the r requested bytes. Some types of channels, depending upon their state, may write only some of the bytes or possibly none at all. A socket channel in non-blocking mode, for example, cannot write any more bytes than are free in the socket's output buffer. This method may be invoked at any time. If another thread has already initiated a write operation upon this channel, however, then an invocation of this method will block until the first operation is complete.
| |
| write | back to summary |
|---|---|
| public int write(ByteBuffer src) throws IOException Overrides jnr. Implements java. Doc from java. Writes a sequence of bytes to this channel from the given buffer. An attempt is made to write up to r bytes to the channel,
where r is the number of bytes remaining in the buffer, that is,
Suppose that a byte sequence of length n is written, where
Unless otherwise specified, a write operation will return only after writing all of the r requested bytes. Some types of channels, depending upon their state, may write only some of the bytes or possibly none at all. A socket channel in non-blocking mode, for example, cannot write any more bytes than are free in the socket's output buffer. This method may be invoked at any time. If another thread has already initiated a write operation upon this channel, however, then an invocation of this method will block until the first operation is complete.
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final Set |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| private static Set |
| defaultOptions | back to summary |
|---|---|
| pack-priv static final Set<SocketOption<?>> defaultOptions | |
| DefaultOptionsHolder | back to summary |
|---|---|
| private DefaultOptionsHolder() | |
| defaultOptions | back to summary |
|---|---|
| private static Set | |
| Modifier and Type | Field and Description |
|---|---|
| public static final UnixSocketChannel. | |
| public static final UnixSocketChannel. | |
| public static final UnixSocketChannel. | |
| public static final UnixSocketChannel. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static UnixSocketChannel. | |
| public static UnixSocketChannel. |
| CONNECTED | back to summary |
|---|---|
| public static final UnixSocketChannel. | |
| CONNECTING | back to summary |
|---|---|
| public static final UnixSocketChannel. | |
| IDLE | back to summary |
|---|---|
| public static final UnixSocketChannel. | |
| UNINITIALIZED | back to summary |
|---|---|
| public static final UnixSocketChannel. | |
| State | back to summary |
|---|---|
| private State() | |
| valueOf | back to summary |
|---|---|
| public static UnixSocketChannel. | |
| values | back to summary |
|---|---|
| public static UnixSocketChannel. | |