Top Description Constructors Methods
org.newsclub.net.unix

public final Class AFUNIXDatagramSocket

extends AFDatagramSocket<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.DatagramSocket, .SocketException

A DatagramSocket implementation that works with AF_UNIX Unix domain sockets.
Author
Christian Kohlschütter

Constructor Summary

AccessConstructor and Description
pack-priv
private

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 AFUNIXDatagramChannel
getChannel()

Overrides org.newsclub.net.unix.AFDatagramSocket.getChannel.

Returns the unique java.nio.channels.DatagramChannel object associated with this datagram socket, if any.

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.

protected AFUNIXDatagramChannel
newChannel()

Implements abstract org.newsclub.net.unix.AFDatagramSocket.newChannel.

Creates a new DatagramChannel that is associated with this socket.

protected AFDatagramSocket<AFUNIXSocketAddress>
newDatagramSocketInstance()

Implements abstract org.newsclub.net.unix.AFDatagramSocket.newDatagramSocketInstance.

Returns a new AFDatagramSocket instance to be used for accept(), i.e., no FileDescriptor is associated.

public static AFUNIXDatagramSocket

Returns:

The new instance.
newInstance
()

Returns a new AFUNIXDatagramSocket instance.

public static AFUNIXDatagramSocket

Returns:

The new instance.
newInstance
(AFSocketType
The socket type.
socketType
)

Returns a new AFUNIXDatagramSocket instance for the given socket type.

pack-priv static AFUNIXDatagramSocket
newInstance(FileDescriptor fdObj, int localPort, int remotePort)

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.AFDatagramSocket:
acceptaccept1addressFamilybindcloseconnectconnectensureAncillaryReceiveBufferSizegetAFImplgetAFImplgetAncillaryDataSupportgetAncillaryReceiveBufferSizegetFileDescriptorgetImplExtensionsgetLocalSocketAddressgetOptiongetRemoteSocketAddressinternalDummyBindinternalDummyConnectisBoundisClosedisConnectedisDeleteOnCloselistennewInstancenewInstancepeekreceivesendsetAncillaryReceiveBufferSizesetDeleteOnClosesetOptionsetShutdownOnClosesocketAddressClass

Constructor Detail

AFUNIXDatagramSocketback to summary
pack-priv AFUNIXDatagramSocket(final FileDescriptor fd) throws IOException
AFUNIXDatagramSocketback to summary
private AFUNIXDatagramSocket(final FileDescriptor fd, AFSocketType socketType) throws IOException

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
getChannelback to summary
public AFUNIXDatagramChannel getChannel()

Overrides org.newsclub.net.unix.AFDatagramSocket.getChannel.

Doc from java.net.DatagramSocket.getChannel.

Returns the unique java.nio.channels.DatagramChannel object associated with this datagram socket, if any.

A datagram socket will have a channel if, and only if, the channel itself was created via the DatagramChannel.open method.

Returns:AFUNIXDatagramChannel

the datagram channel associated with this datagram socket, or null if this socket was not created for a channel

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
newChannelback to summary
protected AFUNIXDatagramChannel newChannel()

Implements abstract org.newsclub.net.unix.AFDatagramSocket.newChannel.

Doc from org.newsclub.net.unix.AFDatagramSocket.newChannel.

Creates a new DatagramChannel that is associated with this socket.

Returns:AFUNIXDatagramChannel

The channel.

Annotations
@Override
newDatagramSocketInstanceback to summary
protected AFDatagramSocket<AFUNIXSocketAddress> newDatagramSocketInstance() throws IOException

Implements abstract org.newsclub.net.unix.AFDatagramSocket.newDatagramSocketInstance.

Doc from org.newsclub.net.unix.AFDatagramSocket.newDatagramSocketInstance.

Returns a new AFDatagramSocket instance to be used for accept(), i.e., no FileDescriptor is associated.

Returns:AFDatagramSocket<AFUNIXSocketAddress>

The new instance.

Annotations
@Override
Exceptions
IOException:
on error.
newInstanceback to summary
public static AFUNIXDatagramSocket newInstance() throws IOException

Returns a new AFUNIXDatagramSocket instance.

Returns:AFUNIXDatagramSocket

The new instance.

Exceptions
IOException:
on error.
newInstanceback to summary
public static AFUNIXDatagramSocket newInstance(AFSocketType socketType) throws IOException

Returns a new AFUNIXDatagramSocket instance for the given socket type.

Parameters
socketType:AFSocketType

The socket type.

Returns:AFUNIXDatagramSocket

The new instance.

Exceptions
IOException:
on error.
newInstanceback to summary
pack-priv static AFUNIXDatagramSocket newInstance(FileDescriptor fdObj, int localPort, int remotePort) throws IOException
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.