Top Description Methods
org.newsclub.net.unix

public Interface AFUNIXSocketExtensions

extends AFSocketExtensions
Known Direct Implementers
org.newsclub.net.unix.AFUNIXDatagramChannel, org.newsclub.net.unix.AFUNIXDatagramSocket, org.newsclub.net.unix.AFUNIXSocket, org.newsclub.net.unix.AFUNIXSocketChannel
Imports
java.io.FileDescriptor, .IOException, .InputStream

Defines certain methods that all junixsocket AF_UNIX socket implementations share and extend beyond the standard socket API. The set of features include methods to support working with ancillary messages (such as file descriptors) as well as socket credentials. Keep in mind that the platform this code runs on may not support these features, and exceptions may be thrown when not checking for the corresponding AFUNIXSocketCapability first.
Author
Christian Kohlschütter

Method Summary

Modifier and TypeMethod and Description
public void
clearReceivedFileDescriptors()

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

public AFUNIXSocketCredentials

Returns:

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

Retrieves the "peer credentials" for this connection.

public FileDescriptor[]

Returns:

The file descriptors, or an empty array if none were available.
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

Returns:

true if there are file descriptors pending.
hasOutboundFileDescriptors
()

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

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

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

Inherited from org.newsclub.net.unix.AFSocketExtensions:
ensureAncillaryReceiveBufferSizegetAncillaryReceiveBufferSizesetAncillaryReceiveBufferSize

Method Detail

clearReceivedFileDescriptorsback to summary
public void clearReceivedFileDescriptors()

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

getPeerCredentialsback to summary
public AFUNIXSocketCredentials getPeerCredentials() throws IOException

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.

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

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.

Exceptions
IOException:
if the operation fails.
hasOutboundFileDescriptorsback to summary
public boolean 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.

setOutboundFileDescriptorsback to summary
public void setOutboundFileDescriptors(FileDescriptor... fdescs) throws IOException

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.

Exceptions
IOException:
if the operation fails.