Top Description Inners Fields Constructors Methods
org.newsclub.net.unix

public abstract Class AFSocketChannel<A extends AFSocketAddress>

extends SocketChannel
implements AFSomeSocket, AFSocketExtensions, AFSomeSocketChannel
Class Inheritance
All Implemented Interfaces
org.newsclub.net.unix.AFSomeSocketChannel, org.newsclub.net.unix.AFSomeSocketThing, org.newsclub.net.unix.FileDescriptorAccess, java.io.Closeable, java.lang.AutoCloseable, java.nio.channels.InterruptibleChannel, java.nio.channels.Channel, org.newsclub.net.unix.AFSocketExtensions, org.newsclub.net.unix.AFSomeSocket
Known Direct Subclasses
org.newsclub.net.unix.AFUNIXSocketChannel, org.newsclub.net.unix.AFGenericSocketChannel
Type Parameters
<A>
The concrete AFSocketAddress that is supported by this type.
Static Imports
java.util.Objects.requireNonNull

A selectable channel for stream-oriented connecting sockets.
Author
Christian Kohlschütter

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static interface
AFSocketChannel.AFSocketSupplier<
The concrete AFSocketAddress that is supported by this type.
A extends AFSocketAddress
>

A reference to a method that provides an AFSocket instance.

Field Summary

Modifier and TypeField and Description
private final @NonNull AFSocket<A>
private final AtomicBoolean

Constructor Summary

AccessConstructor and Description
protected
AFSocketChannel(AFSocket<A>
The socket.
socket
,
AFSelectorProvider<A> sp)

Creates a new socket channel for the given socket, using the given SelectorProvider.

Method Summary

Modifier and TypeMethod and Description
public final AFSocketChannel<A>
bind(SocketAddress
The address to bind the socket, or null to bind the socket to an automatically assigned socket address
local
)

Implements abstract java.nio.channels.SocketChannel.bind.

Implements java.nio.channels.NetworkChannel.bind.

Binds the channel's socket to a local address.

public final boolean
connect(SocketAddress
The remote address to which this channel is to be connected
remote
)

Implements abstract java.nio.channels.SocketChannel.connect.

Connects this channel's socket.

public final void
ensureAncillaryReceiveBufferSize(int
The minimum size (in bytes).
minSize
)

Implements org.newsclub.net.unix.AFSocketExtensions.ensureAncillaryReceiveBufferSize.

Ensures a minimum ancillary receive buffer size.

public final boolean
finishConnect()

Implements abstract java.nio.channels.SocketChannel.finishConnect.

Finishes the process of connecting a socket channel.

pack-priv final AFSocketCore
protected final AFSocket<A>

Returns:

The corresponding socket.
getAFSocket
()

Returns the corresponding AFSocket.

public final int
getAncillaryReceiveBufferSize()

Implements org.newsclub.net.unix.AFSocketExtensions.getAncillaryReceiveBufferSize.

Returns the size of the receive buffer for ancillary messages (in bytes).

public final FileDescriptor
public final A
getLocalAddress()

Implements abstract java.nio.channels.SocketChannel.getLocalAddress.

Implements java.nio.channels.NetworkChannel.getLocalAddress.

Returns the socket address that this channel's socket is bound to.

public final A
getLocalSocketAddress()

Implements org.newsclub.net.unix.AFSomeSocketThing.getLocalSocketAddress.

Returns the socket's local socket address, or null if unavailable or if there was a problem retrieving it.

public final <T> T
getOption(SocketOption<T>
The socket option
name
)

Implements java.nio.channels.NetworkChannel.getOption.

Returns the value of a socket option.

public final A
getRemoteAddress()

Implements abstract java.nio.channels.SocketChannel.getRemoteAddress.

Returns the remote address to which this channel's socket is connected.

public final A
getRemoteSocketAddress()

Implements org.newsclub.net.unix.AFSomeSocket.getRemoteSocketAddress.

Returns the socket's remote socket address, or null if unavailable/not connected, or if there was a problem retrieving it.

protected final void
protected final void
implConfigureBlocking(boolean
If true then this channel will be placed in blocking mode; if false then it will be placed non-blocking mode
block
)

Implements abstract java.nio.channels.spi.AbstractSelectableChannel.implConfigureBlocking.

Adjusts this channel's blocking mode.

public final boolean
isConnected()

Implements abstract java.nio.channels.SocketChannel.isConnected.

Tells whether or not this channel's network socket is connected.

public final boolean
isConnectionPending()

Implements abstract java.nio.channels.SocketChannel.isConnectionPending.

Tells whether or not a connection operation is in progress on this channel.

protected static final <
The concrete AFSocketAddress that is supported by this type.
A extends AFSocketAddress
>
AFSocketChannel<A>

Returns:

The new channel
open
(AFSocketChannel.AFSocketSupplier<A>
The AFSocketChannel constructor.
supplier
)

Opens a socket channel.

protected static final <
The concrete AFSocketAddress that is supported by this type.
A extends AFSocketAddress
>
AFSocketChannel<A>

Returns:

The new channel
open
(AFSocketChannel.AFSocketSupplier<A>
The AFSocketChannel constructor.
supplier
,
SocketAddress
The socket address to connect to.
remote
)

Opens a socket channel, connecting to the given socket address.

public static SocketChannel

Returns:

The new SocketChannel.
open
(ProtocolFamily
The protocol family.
family
)

Hides java.nio.channels.SocketChannel.open.

Opens a socket channel.

public final int
read(ByteBuffer
The buffer into which bytes are to be transferred
dst
)

Implements abstract java.nio.channels.SocketChannel.read.

Implements java.nio.channels.ReadableByteChannel.read.

Reads a sequence of bytes from this channel into the given buffer.

public final long
read(ByteBuffer[]
The buffers into which bytes are to be transferred
dsts
,
int
The offset within the buffer array of the first buffer into which bytes are to be transferred; must be non-negative and no larger than dsts.length
offset
,
int
The maximum number of buffers to be accessed; must be non-negative and no larger than dsts.length - offset
length
)

Implements abstract java.nio.channels.SocketChannel.read.

Implements java.nio.channels.ScatteringByteChannel.read.

Reads a sequence of bytes from this channel into a subsequence of the given buffers.

public final void
setAncillaryReceiveBufferSize(int
The size.
size
)

Implements org.newsclub.net.unix.AFSocketExtensions.setAncillaryReceiveBufferSize.

Sets the size of the receive buffer for ancillary messages (in bytes).

public final <T> AFSocketChannel<A>
setOption(SocketOption<T>
The socket option
name
,
T
The value of the socket option. A value of null may be a valid value for some socket options.
value
)

Implements abstract java.nio.channels.SocketChannel.setOption.

Implements java.nio.channels.NetworkChannel.setOption.

Sets the value of a socket option.

public void
setShutdownOnClose(boolean
true if enabled.
enabled
)

Implements org.newsclub.net.unix.AFSomeSocketThing.setShutdownOnClose.

Configures whether the socket should be shutdown upon close(), which is the default.

public final AFSocketChannel<A>
shutdownInput()

Implements abstract java.nio.channels.SocketChannel.shutdownInput.

Shutdown the connection for reading without closing the channel.

public final AFSocketChannel<A>
shutdownOutput()

Implements abstract java.nio.channels.SocketChannel.shutdownOutput.

Shutdown the connection for writing without closing the channel.

public final AFSocket<A>
socket()

Implements abstract java.nio.channels.SocketChannel.socket.

Retrieves a socket associated with this channel.

public final Set<SocketOption<?>>
supportedOptions()

Implements java.nio.channels.NetworkChannel.supportedOptions.

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

public final String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public final 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 srcs.length
offset
,
int
The maximum number of buffers to be accessed; must be non-negative and no larger than srcs.length - offset
length
)

Implements abstract java.nio.channels.SocketChannel.write.

Implements java.nio.channels.GatheringByteChannel.write.

Writes a sequence of bytes to this channel from a subsequence of the given buffers.

public final int
write(ByteBuffer
The buffer from which bytes are to be retrieved
src
)

Implements abstract java.nio.channels.SocketChannel.write.

Implements java.nio.channels.WritableByteChannel.write.

Writes a sequence of bytes to this channel from the given buffer.

Inherited from java.nio.channels.SocketChannel:
openopenreadvalidOpswrite

Field Detail

afSocketback to summary
private final @NonNull AFSocket<A> afSocket
connectPendingback to summary
private final AtomicBoolean connectPending

Constructor Detail

AFSocketChannelback to summary
protected AFSocketChannel(AFSocket<A> socket, AFSelectorProvider<A> sp)

Creates a new socket channel for the given socket, using the given SelectorProvider.

Parameters
socket:AFSocket<A>

The socket.

sp:AFSelectorProvider<A>

The SelectorProvider.

Annotations
@SuppressWarnings:all

Method Detail

bindback to summary
public final AFSocketChannel<A> bind(SocketAddress local) throws IOException

Implements abstract java.nio.channels.SocketChannel.bind.

Implements java.nio.channels.NetworkChannel.bind.

Doc from java.nio.channels.SocketChannel.bind.

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 local parameter has the value null then the socket will be bound to an address that is assigned automatically.

Parameters
local:SocketAddress

The address to bind the socket, or null to bind the socket to an automatically assigned socket address

Returns:AFSocketChannel<A>

This channel

Annotations
@Override
Exceptions
IOException:
If some other I/O error occurs
connectback to summary
public final boolean connect(SocketAddress remote) throws IOException

Implements abstract java.nio.channels.SocketChannel.connect.

Doc from java.nio.channels.SocketChannel.connect.

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 true. Otherwise this method returns false and the connection operation must later be completed by invoking the finishConnect method.

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.

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.

Parameters
remote:SocketAddress

The remote address to which this channel is to be connected

Returns:boolean

true if a connection was established, false if this channel is in non-blocking mode and the connection operation is in progress

Annotations
@Override
Exceptions
IOException:
If some other I/O error occurs
ensureAncillaryReceiveBufferSizeback to summary
public final void ensureAncillaryReceiveBufferSize(int minSize)

Implements org.newsclub.net.unix.AFSocketExtensions.ensureAncillaryReceiveBufferSize.

Doc from org.newsclub.net.unix.AFSocketExtensions.ensureAncillaryReceiveBufferSize.

Ensures a minimum ancillary receive buffer size.

Parameters
minSize:int

The minimum size (in bytes).

Annotations
@Override
finishConnectback to summary
public final boolean finishConnect() throws IOException

Implements abstract java.nio.channels.SocketChannel.finishConnect.

Doc from java.nio.channels.SocketChannel.finishConnect.

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 connect method. Once the connection is established, or the attempt has failed, the socket channel will become connectable and this method may be invoked to complete the connection sequence. If the connection operation failed then invoking this method will cause an appropriate java.io.IOException to be thrown.

If this channel is already connected then this method will not block and will immediately return true. If this channel is in non-blocking mode then this method will return false if the connection process is not yet complete. If this channel is in blocking mode then this method will block until the connection either completes or fails, and will always either return true or throw a checked exception describing the failure.

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.

Returns:boolean

true if, and only if, this channel's socket is now connected

Annotations
@Override
Exceptions
IOException:
If some other I/O error occurs
getAFCoreback to summary
pack-priv final AFSocketCore getAFCore()
getAFSocketback to summary
protected final AFSocket<A> getAFSocket()

Returns the corresponding AFSocket.

Returns:AFSocket<A>

The corresponding socket.

getAncillaryReceiveBufferSizeback to summary
public final int getAncillaryReceiveBufferSize()

Implements org.newsclub.net.unix.AFSocketExtensions.getAncillaryReceiveBufferSize.

Doc from org.newsclub.net.unix.AFSocketExtensions.getAncillaryReceiveBufferSize.

Returns the size of the receive buffer for ancillary messages (in bytes).

Returns:int

The size.

Annotations
@Override
getFileDescriptorback to summary
public final FileDescriptor getFileDescriptor() throws IOException

Implements org.newsclub.net.unix.FileDescriptorAccess.getFileDescriptor.

Doc from org.newsclub.net.unix.FileDescriptorAccess.getFileDescriptor.

Returns the corresponding FileDescriptor.

Returns:FileDescriptor

The corresponding FileDescriptor.

Annotations
@Override
Exceptions
IOException:
on error.
getLocalAddressback to summary
public final A getLocalAddress() throws IOException

Implements abstract java.nio.channels.SocketChannel.getLocalAddress.

Implements java.nio.channels.NetworkChannel.getLocalAddress.

Doc from java.nio.channels.SocketChannel.getLocalAddress.

Returns the socket address that this channel's socket is bound to.

Where the channel is bound to an Internet Protocol socket address then the return value from this method is of type java.net.InetSocketAddress.

Where the channel is bound to a Unix Domain socket address, the socket address is a UnixDomainSocketAddress.

Returns:A

The SocketAddress that the socket is bound to; null if the channel's socket is not bound

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
getLocalSocketAddressback to summary
public final A getLocalSocketAddress()

Implements org.newsclub.net.unix.AFSomeSocketThing.getLocalSocketAddress.

Doc from org.newsclub.net.unix.AFSomeSocketThing.getLocalSocketAddress.

Returns the socket's local socket address, or null if unavailable or if there was a problem retrieving it.

Returns:A

The local socket address, or null.

Annotations
@Override
getOptionback to summary
public final <T> T getOption(SocketOption<T> name) throws IOException

Implements java.nio.channels.NetworkChannel.getOption.

Doc from java.nio.channels.NetworkChannel.getOption.

Returns the value of a socket option.

Parameters
<T>
The type of the socket option value
name:SocketOption<T>

The socket option

Returns:T

The value of the socket option. A value of null may be a valid value for some socket options.

Annotations
@SuppressWarnings:unchecked
@Override
Exceptions
IOException:
If an I/O error occurs
getRemoteAddressback to summary
public final A getRemoteAddress() throws IOException

Implements abstract java.nio.channels.SocketChannel.getRemoteAddress.

Doc from java.nio.channels.SocketChannel.getRemoteAddress.

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 java.net.InetSocketAddress.

Where the channel's socket is bound and connected to a Unix Domain socket address, the returned address is a UnixDomainSocketAddress.

Returns:A

The remote address; null if the channel's socket is not connected

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
getRemoteSocketAddressback to summary
public final A getRemoteSocketAddress()

Implements org.newsclub.net.unix.AFSomeSocket.getRemoteSocketAddress.

Doc from org.newsclub.net.unix.AFSomeSocket.getRemoteSocketAddress.

Returns the socket's remote socket address, or null if unavailable/not connected, or if there was a problem retrieving it.

Returns:A

The remote socket address, or null.

Annotations
@Override
implCloseSelectableChannelback to summary
protected final void implCloseSelectableChannel() throws IOException

Implements abstract java.nio.channels.spi.AbstractSelectableChannel.implCloseSelectableChannel.

Doc from java.nio.channels.spi.AbstractSelectableChannel.implCloseSelectableChannel.

Closes this selectable channel.

This method is invoked by the close method in order to perform the actual work of closing the channel. This method is only invoked if the channel has not yet been closed, and it is never invoked more than once.

An implementation of this method must arrange for any other thread that is blocked in an I/O operation upon this channel to return immediately, either by throwing an exception or by returning normally.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
implConfigureBlockingback to summary
protected final void implConfigureBlocking(boolean block) throws IOException

Implements abstract java.nio.channels.spi.AbstractSelectableChannel.implConfigureBlocking.

Doc from java.nio.channels.spi.AbstractSelectableChannel.implConfigureBlocking.

Adjusts this channel's blocking mode.

This method is invoked by the configureBlocking method in order to perform the actual work of changing the blocking mode. This method is only invoked if the new mode is different from the current mode.

Parameters
block:boolean

If true then this channel will be placed in blocking mode; if false then it will be placed non-blocking mode

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
isConnectedback to summary
public final boolean isConnected()

Implements abstract java.nio.channels.SocketChannel.isConnected.

Doc from java.nio.channels.SocketChannel.isConnected.

Tells whether or not this channel's network socket is connected.

Returns:boolean

true if, and only if, this channel's network socket is open and connected

Annotations
@Override
isConnectionPendingback to summary
public final boolean isConnectionPending()

Implements abstract java.nio.channels.SocketChannel.isConnectionPending.

Doc from java.nio.channels.SocketChannel.isConnectionPending.

Tells whether or not a connection operation is in progress on this channel.

Returns:boolean

true if, and only if, a connection operation has been initiated on this channel but not yet completed by invoking the finishConnect method

Annotations
@Override
openback to summary
protected static final <A extends AFSocketAddress> AFSocketChannel<A> open(AFSocketChannel.AFSocketSupplier<A> supplier) throws IOException

Opens a socket channel.

Parameters
<A>
The concrete AFSocketAddress that is supported by this type.
supplier:AFSocketChannel.AFSocketSupplier<A>

The AFSocketChannel constructor.

Returns:AFSocketChannel<A>

The new channel

Exceptions
IOException:
on error.
openback to summary
protected static final <A extends AFSocketAddress> AFSocketChannel<A> open(AFSocketChannel.AFSocketSupplier<A> supplier, SocketAddress remote) throws IOException

Opens a socket channel, connecting to the given socket address.

Parameters
<A>
The concrete AFSocketAddress that is supported by this type.
supplier:AFSocketChannel.AFSocketSupplier<A>

The AFSocketChannel constructor.

remote:SocketAddress

The socket address to connect to.

Returns:AFSocketChannel<A>

The new channel

Exceptions
IOException:
on error.
openback to summary
public static SocketChannel open(ProtocolFamily family) throws IOException

Hides java.nio.channels.SocketChannel.open.

Opens a socket channel. The family parameter specifies the protocol family of the channel's socket.

If the ProtocolFamily is of an AFProtocolFamily, or UNIX, the corresponding junixsocket implementation is used. In all other cases, the call is delegated to SocketChannel#open().

Parameters
family:ProtocolFamily

The protocol family.

Returns:SocketChannel

The new SocketChannel.

Exceptions
IOException:
on error.
readback to summary
public final int read(ByteBuffer dst) throws IOException

Implements abstract java.nio.channels.SocketChannel.read.

Implements java.nio.channels.ReadableByteChannel.read.

Doc from java.nio.channels.ReadableByteChannel.read.

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, dst.remaining(), at the moment this method is invoked.

Suppose that a byte sequence of length n is read, where 0 <= n <= r. This byte sequence will be transferred into the buffer so that the first byte in the sequence is at index p and the last byte is at index p + n - 1, where p is the buffer's position at the moment this method is invoked. Upon return the buffer's position will be equal to p + n; its limit will not have changed.

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.

Parameters
dst:ByteBuffer

The buffer into which bytes are to be transferred

Returns:int

The number of bytes read, possibly zero, or -1 if the channel has reached end-of-stream

Annotations
@Override
Exceptions
IOException:
If some other I/O error occurs
readback to summary
public final long read(ByteBuffer[] dsts, int offset, int length) throws IOException

Implements abstract java.nio.channels.SocketChannel.read.

Implements java.nio.channels.ScatteringByteChannel.read.

Doc from java.nio.channels.ScatteringByteChannel.read.

Reads a sequence of bytes from this channel into a subsequence of the given buffers.

An invocation of this method attempts to read up to r bytes from this channel, where r is the total number of bytes remaining in the specified subsequence of the given buffer array, that is,

dsts[offset].remaining() + dsts[offset+1].remaining() + ... + dsts[offset+length-1].remaining()
dsts[offset].remaining()
    + dsts[offset+1].remaining()
    + ... + dsts[offset+length-1].remaining()
at the moment that this method is invoked.

Suppose that a byte sequence of length n is read, where 0 <= n <= r. Up to the first dsts[offset].remaining() bytes of this sequence are transferred into buffer dsts[offset], up to the next dsts[offset+1].remaining() bytes are transferred into buffer dsts[offset+1], and so forth, until the entire byte sequence is transferred into the given buffers. As many bytes as possible are transferred into each buffer, hence the final position of each updated buffer, except the last updated buffer, is guaranteed to be equal to that buffer's limit.

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.

Parameters
dsts:ByteBuffer[]

The buffers into which bytes are to be transferred

offset:int

The offset within the buffer array of the first buffer into which bytes are to be transferred; must be non-negative and no larger than dsts.length

length:int

The maximum number of buffers to be accessed; must be non-negative and no larger than dsts.length - offset

Returns:long

The number of bytes read, possibly zero, or -1 if the channel has reached end-of-stream

Annotations
@Override
Exceptions
IOException:
If some other I/O error occurs
setAncillaryReceiveBufferSizeback to summary
public final void setAncillaryReceiveBufferSize(int size)

Implements org.newsclub.net.unix.AFSocketExtensions.setAncillaryReceiveBufferSize.

Doc from org.newsclub.net.unix.AFSocketExtensions.setAncillaryReceiveBufferSize.

Sets the size of the receive buffer for ancillary messages (in bytes). To disable handling ancillary messages, set it to 0 (default).

Parameters
size:int

The size.

Annotations
@Override
setOptionback to summary
public final <T> AFSocketChannel<A> setOption(SocketOption<T> name, T value) throws IOException

Implements abstract java.nio.channels.SocketChannel.setOption.

Implements java.nio.channels.NetworkChannel.setOption.

Doc from java.nio.channels.NetworkChannel.setOption.

Sets the value of a socket option.

Parameters
<T>
The type of the socket option value
name:SocketOption<T>

The socket option

value:T

The value of the socket option. A value of null may be a valid value for some socket options.

Returns:AFSocketChannel<A>

This channel

Annotations
@Override
Exceptions
IOException:

Doc from java.nio.channels.SocketChannel.setOption.

If an I/O error occurs

setShutdownOnCloseback to summary
public void setShutdownOnClose(boolean enabled)

Implements org.newsclub.net.unix.AFSomeSocketThing.setShutdownOnClose.

Doc from org.newsclub.net.unix.AFSomeSocketThing.setShutdownOnClose.

Configures whether the socket should be shutdown upon close(), which is the default.

Parameters
enabled:boolean

true if enabled.

Annotations
@Override
shutdownInputback to summary
public final AFSocketChannel<A> shutdownInput() throws IOException

Implements abstract java.nio.channels.SocketChannel.shutdownInput.

Doc from java.nio.channels.SocketChannel.shutdownInput.

Shutdown the connection for reading without closing the channel.

Once shutdown for reading then further reads on the channel will return -1, the end-of-stream indication. If the input side of the connection is already shutdown then invoking this method has no effect.

Returns:AFSocketChannel<A>

The channel

Annotations
@Override
Exceptions
IOException:
If some other I/O error occurs
shutdownOutputback to summary
public final AFSocketChannel<A> shutdownOutput() throws IOException

Implements abstract java.nio.channels.SocketChannel.shutdownOutput.

Doc from java.nio.channels.SocketChannel.shutdownOutput.

Shutdown the connection for writing without closing the channel.

Once shutdown for writing then further attempts to write to the channel will throw ClosedChannelException. If the output side of the connection is already shutdown then invoking this method has no effect.

Returns:AFSocketChannel<A>

The channel

Annotations
@Override
Exceptions
IOException:
If some other I/O error occurs
socketback to summary
public final AFSocket<A> socket()

Implements abstract java.nio.channels.SocketChannel.socket.

Doc from java.nio.channels.SocketChannel.socket.

Retrieves a socket associated with this channel.

Returns:AFSocket<A>

A socket associated with this channel

Annotations
@Override
@SuppressFBWarnings:EI_EXPOSE_REP
supportedOptionsback to summary
public final Set<SocketOption<?>> supportedOptions()

Implements java.nio.channels.NetworkChannel.supportedOptions.

Doc from java.nio.channels.NetworkChannel.supportedOptions.

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.

Returns:Set<SocketOption<?>>

A set of the socket options supported by this channel

Annotations
@Override
toStringback to summary
public final String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
writeback to summary
public final long write(ByteBuffer[] srcs, int offset, int length) throws IOException

Implements abstract java.nio.channels.SocketChannel.write.

Implements java.nio.channels.GatheringByteChannel.write.

Doc from java.nio.channels.GatheringByteChannel.write.

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()
srcs[offset].remaining()
    + srcs[offset+1].remaining()
    + ... + srcs[offset+length-1].remaining()
at the moment that this method is invoked.

Suppose that a byte sequence of length n is written, where 0 <= n <= r. Up to the first srcs[offset].remaining() bytes of this sequence are written from buffer srcs[offset], up to the next srcs[offset+1].remaining() bytes are written from buffer srcs[offset+1], and so forth, until the entire byte sequence is written. As many bytes as possible are written from each buffer, hence the final position of each updated buffer, except the last updated buffer, is guaranteed to be equal to that buffer's limit.

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.

Parameters
srcs:ByteBuffer[]

The buffers from which bytes are to be retrieved

offset: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 srcs.length

length:int

The maximum number of buffers to be accessed; must be non-negative and no larger than srcs.length - offset

Returns:long

The number of bytes written, possibly zero

Annotations
@Override
Exceptions
IOException:
If some other I/O error occurs
writeback to summary
public final int write(ByteBuffer src) throws IOException

Implements abstract java.nio.channels.SocketChannel.write.

Implements java.nio.channels.WritableByteChannel.write.

Doc from java.nio.channels.WritableByteChannel.write.

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, src.remaining(), at the moment this method is invoked.

Suppose that a byte sequence of length n is written, where 0 <= n <= r. This byte sequence will be transferred from the buffer starting at index p, where p is the buffer's position at the moment this method is invoked; the index of the last byte written will be p + n - 1. Upon return the buffer's position will be equal to p + n; its limit will not have changed.

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.

Parameters
src:ByteBuffer

The buffer from which bytes are to be retrieved

Returns:int

The number of bytes written, possibly zero

Annotations
@Override
Exceptions
IOException:
If some other I/O error occurs
org.newsclub.net.unix back to summary

protected Interface AFSocketChannel.AFSocketSupplier<A extends AFSocketAddress>

Annotations
@FunctionalInterface
Type Parameters
<A>
The concrete AFSocketAddress that is supported by this type.

A reference to a method that provides an AFSocket instance.

Method Summary

Modifier and TypeMethod and Description
public AFSocket<A>

Returns:

The instance.
newInstance
()

Returns a new AFSocket instance.

Method Detail

newInstanceback to summary
public AFSocket<A> newInstance() throws IOException

Returns a new AFSocket instance.

Returns:AFSocket<A>

The instance.

Exceptions
IOException:
on error.