Class AFUNIXSocketChannel

All Implemented Interfaces:
Closeable, AutoCloseable, ByteChannel, Channel, GatheringByteChannel, InterruptibleChannel, NetworkChannel, ReadableByteChannel, ScatteringByteChannel, WritableByteChannel, AFSocketExtensions, AFSomeSocket, AFUNIXSocketExtensions, FileDescriptorAccess

public final class AFUNIXSocketChannel extends AFSocketChannel<AFUNIXSocketAddress> implements AFUNIXSocketExtensions
A selectable channel for stream-oriented connecting sockets.
Author:
Christian Kohlschütter
  • Method Details

    • open

      public static AFUNIXSocketChannel open() throws IOException
      Opens a socket channel.
      Returns:
      The new channel
      Throws:
      IOException - on error.
    • open

      public static AFUNIXSocketChannel open(SocketAddress remote) throws IOException
      Opens a socket channel, connecting to the given socket address.
      Parameters:
      remote - The socket address to connect to.
      Returns:
      The new channel
      Throws:
      IOException - on error.
    • getReceivedFileDescriptors

      public FileDescriptor[] getReceivedFileDescriptors() throws IOException
      Description copied from interface: AFUNIXSocketExtensions
      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).
      Specified by:
      getReceivedFileDescriptors in interface AFUNIXSocketExtensions
      Returns:
      The file descriptors, or an empty array if none were available.
      Throws:
      IOException - if the operation fails.
    • clearReceivedFileDescriptors

      public void clearReceivedFileDescriptors()
      Description copied from interface: AFUNIXSocketExtensions
      Clears the queue of incoming FileDescriptors that were sent as ancillary messages.
      Specified by:
      clearReceivedFileDescriptors in interface AFUNIXSocketExtensions
    • setOutboundFileDescriptors

      public void setOutboundFileDescriptors(FileDescriptor... fdescs) throws IOException
      Description copied from interface: AFUNIXSocketExtensions
      Sets a list of FileDescriptors that should be sent as an ancillary message along with the next write. Important: 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.
      Specified by:
      setOutboundFileDescriptors in interface AFUNIXSocketExtensions
      Parameters:
      fdescs - The file descriptors, or null if none.
      Throws:
      IOException - if the operation fails.
    • hasOutboundFileDescriptors

      public boolean hasOutboundFileDescriptors()
      Description copied from interface: AFUNIXSocketExtensions
      Returns true if there are pending file descriptors to be sent as part of an ancillary message.
      Specified by:
      hasOutboundFileDescriptors in interface AFUNIXSocketExtensions
      Returns:
      true if there are file descriptors pending.
    • getPeerCredentials

      public AFUNIXSocketCredentials getPeerCredentials() throws IOException
      Description copied from interface: AFUNIXSocketExtensions
      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.
      Specified by:
      getPeerCredentials in interface AFUNIXSocketExtensions
      Returns:
      The peer's credentials, or null if they couldn't be retrieved.
      Throws:
      IOException - If there was an error returning these credentials.