Class AFSYSTEMSocket

java.lang.Object
java.net.Socket
org.newsclub.net.unix.AFSocket<org.newsclub.net.unix.AFSYSTEMSocketAddress>
org.newsclub.net.unix.darwin.system.AFSYSTEMSocket
All Implemented Interfaces:
Closeable, AutoCloseable, org.newsclub.net.unix.AFSocketExtensions, org.newsclub.net.unix.AFSomeSocket, org.newsclub.net.unix.AFSomeSocketThing, AFSYSTEMSocketExtensions, org.newsclub.net.unix.FileDescriptorAccess

public final class AFSYSTEMSocket extends org.newsclub.net.unix.AFSocket<org.newsclub.net.unix.AFSYSTEMSocketAddress> implements AFSYSTEMSocketExtensions
Implementation of an AF_SYSTEM socket.
Author:
Christian Kohlschütter
  • Method Details

    • isSupported

      public static boolean isSupported()
      Returns true iff AFSYSTEMSockets (sockets of type "AF_SYSTEM") are supported by the current Java VM and the kernel. To support AFSYSTEMSockets, a custom JNI library must be loaded that is supplied with junixsocket, and the system must support AF_SYSTEM sockets. This call is equivalent to checking AFSocket.isSupported() and AFSocket.supports(AFSocketCapability) with AFSocketCapability.CAPABILITY_DARWIN.
      Returns:
      true iff supported.
    • newChannel

      protected AFSYSTEMSocketChannel newChannel()
      Specified by:
      newChannel in class org.newsclub.net.unix.AFSocket<org.newsclub.net.unix.AFSYSTEMSocketAddress>
    • newInstance

      public static AFSYSTEMSocket newInstance() throws IOException
      Creates a new, unbound AFSocket. This "default" implementation is a bit "lenient" with respect to the specification. In particular, we ignore calls to Socket.getTcpNoDelay() and Socket.setTcpNoDelay(boolean).
      Returns:
      A new, unbound socket.
      Throws:
      IOException - if the operation fails.
    • newStrictInstance

      public static AFSYSTEMSocket newStrictInstance() throws IOException
      Creates a new, unbound, "strict" AFSocket. This call uses an implementation that tries to be closer to the specification than newInstance(), at least for some cases.
      Returns:
      A new, unbound socket.
      Throws:
      IOException - if the operation fails.
    • connectTo

      public static AFSYSTEMSocket connectTo(org.newsclub.net.unix.AFSYSTEMSocketAddress addr) throws IOException
      Creates a new AFSocket and connects it to the given AFSYSTEMSocketAddress.
      Parameters:
      addr - The address to connect to.
      Returns:
      A new, connected socket.
      Throws:
      IOException - if the operation fails.
    • getChannel

      public AFSYSTEMSocketChannel getChannel()
      Overrides:
      getChannel in class org.newsclub.net.unix.AFSocket<org.newsclub.net.unix.AFSYSTEMSocketAddress>
    • main

      public static void main(String[] args)
      Very basic self-test function. Prints "supported" and "capabilities" status to System.out.
      Parameters:
      args - ignored.