Top Description Constructors Methods
org.newsclub.net.unix

public final Class AFUNIXSocketChannel

extends AFSocketChannel<AFUNIXSocketAddress>
implements AFUNIXSocketExtensions
Class Inheritance
All Implemented Interfaces
org.newsclub.net.unix.AFUNIXSocketExtensions, org.newsclub.net.unix.AFSocketExtensions
Imports
java.io.FileDescriptor, .IOException, java.net.SocketAddress, .SocketException

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

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
clearReceivedFileDescriptors()

Implements org.newsclub.net.unix.AFUNIXSocketExtensions.clearReceivedFileDescriptors.

Clears the queue of incoming FileDescriptors that were sent as ancillary messages.

public AFUNIXSocketCredentials
getPeerCredentials()

Implements org.newsclub.net.unix.AFUNIXSocketExtensions.getPeerCredentials.

Retrieves the "peer credentials" for this connection.

public FileDescriptor[]
getReceivedFileDescriptors()

Implements org.newsclub.net.unix.AFUNIXSocketExtensions.getReceivedFileDescriptors.

Retrieves an array of incoming FileDescriptors that were sent as ancillary messages, along with a call to InputStream#read(), etc.

Note

Another call to this method will not return the same file descriptors again (most likely, an empty array will be returned).

public boolean
hasOutboundFileDescriptors()

Implements org.newsclub.net.unix.AFUNIXSocketExtensions.hasOutboundFileDescriptors.

Returns true if there are pending file descriptors to be sent as part of an ancillary message.

public static AFUNIXSocketChannel

Returns:

The new channel
open
()

Hides java.nio.channels.SocketChannel.open.

Opens a socket channel.

public static AFUNIXSocketChannel

Returns:

The new channel
open
(SocketAddress
The socket address to connect to.
remote
)

Hides java.nio.channels.SocketChannel.open.

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

public void
setOutboundFileDescriptors(FileDescriptor...
The file descriptors, or null if none.
fdescs
)

Implements org.newsclub.net.unix.AFUNIXSocketExtensions.setOutboundFileDescriptors.

Sets a list of FileDescriptors that should be sent as an ancillary message along with the next write.

Inherited from org.newsclub.net.unix.AFSocketChannel:
bindconnectensureAncillaryReceiveBufferSizefinishConnectgetAFCoregetAFSocketgetAncillaryReceiveBufferSizegetFileDescriptorgetLocalAddressgetLocalSocketAddressgetOptiongetRemoteAddressgetRemoteSocketAddressimplCloseSelectableChannelimplConfigureBlockingisConnectedisConnectionPendingopenopenopenreadreadsetAncillaryReceiveBufferSizesetOptionsetShutdownOnCloseshutdownInputshutdownOutputsocketsupportedOptionstoStringwritewrite

Constructor Detail

AFUNIXSocketChannelback to summary
pack-priv AFUNIXSocketChannel(AFUNIXSocket socket)

Method Detail

clearReceivedFileDescriptorsback to summary
public void clearReceivedFileDescriptors()

Implements org.newsclub.net.unix.AFUNIXSocketExtensions.clearReceivedFileDescriptors.

Doc from org.newsclub.net.unix.AFUNIXSocketExtensions.clearReceivedFileDescriptors.

Clears the queue of incoming FileDescriptors that were sent as ancillary messages.

Annotations
@Override
getPeerCredentialsback to summary
public AFUNIXSocketCredentials getPeerCredentials() throws IOException

Implements org.newsclub.net.unix.AFUNIXSocketExtensions.getPeerCredentials.

Doc from org.newsclub.net.unix.AFUNIXSocketExtensions.getPeerCredentials.

Retrieves the "peer credentials" for this connection. These credentials may be useful to authenticate the other end of the socket (client or server). Depending on the socket/connection/environment, you may not receive any or all credentials. For example, on Linux, AFUNIXDatagramSocket and AFUNIXDatagramChannel may not be able to retrieve credentials at all.

Returns:AFUNIXSocketCredentials

The peer's credentials, or null if they couldn't be retrieved.

Annotations
@Override
Exceptions
IOException:
If there was an error returning these credentials.
getReceivedFileDescriptorsback to summary
public FileDescriptor[] getReceivedFileDescriptors() throws IOException

Implements org.newsclub.net.unix.AFUNIXSocketExtensions.getReceivedFileDescriptors.

Doc from org.newsclub.net.unix.AFUNIXSocketExtensions.getReceivedFileDescriptors.

Retrieves an array of incoming FileDescriptors that were sent as ancillary messages, along with a call to InputStream#read(), etc.

Note

Another call to this method will not return the same file descriptors again (most likely, an empty array will be returned).

Returns:FileDescriptor[]

The file descriptors, or an empty array if none were available.

Annotations
@Override
Exceptions
IOException:
if the operation fails.
hasOutboundFileDescriptorsback to summary
public boolean hasOutboundFileDescriptors()

Implements org.newsclub.net.unix.AFUNIXSocketExtensions.hasOutboundFileDescriptors.

Doc from org.newsclub.net.unix.AFUNIXSocketExtensions.hasOutboundFileDescriptors.

Returns true if there are pending file descriptors to be sent as part of an ancillary message.

Returns:boolean

true if there are file descriptors pending.

Annotations
@Override
openback to summary
public static AFUNIXSocketChannel open() throws IOException

Hides java.nio.channels.SocketChannel.open.

Opens a socket channel.

Returns:AFUNIXSocketChannel

The new channel

Exceptions
IOException:
on error.
openback to summary
public static AFUNIXSocketChannel open(SocketAddress remote) throws IOException

Hides java.nio.channels.SocketChannel.open.

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

Parameters
remote:SocketAddress

The socket address to connect to.

Returns:AFUNIXSocketChannel

The new channel

Exceptions
IOException:
on error.
setOutboundFileDescriptorsback to summary
public void setOutboundFileDescriptors(FileDescriptor... fdescs) throws IOException

Implements org.newsclub.net.unix.AFUNIXSocketExtensions.setOutboundFileDescriptors.

Doc from org.newsclub.net.unix.AFUNIXSocketExtensions.setOutboundFileDescriptors.

Sets a list of FileDescriptors that should be sent as an ancillary message along with the next write.

Important Note

There can only be one set of file descriptors active until the write completes. The socket also needs to be connected for this operation to succeed. It is also important to know that there may be an upper limit imposed by the operation system as to how many file descriptors can be sent at once. Linux, for example, may support up to 253. If the number of file descriptors exceeds the limit, an exception may be thrown when sending data along with the ancillary message containing the file descriptors.

Parameters
fdescs:FileDescriptor[]

The file descriptors, or null if none.

Annotations
@Override
Exceptions
IOException:
if the operation fails.