Class AFTIPCSocket

All Implemented Interfaces:
Closeable, AutoCloseable, AFSocketExtensions, AFSomeSocket, AFSomeSocketThing, FileDescriptorAccess, AFTIPCSocketExtensions

public final class AFTIPCSocket extends AFSocket<AFTIPCSocketAddress> implements AFTIPCSocketExtensions
Implementation of an AF_TIPC socket.
Author:
Christian Kohlschütter
  • Method Details

    • isSupported

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

      protected AFTIPCSocketChannel newChannel()
      Description copied from class: AFSocket
      Creates a new AFSocketChannel for this socket.
      Specified by:
      newChannel in class AFSocket<AFTIPCSocketAddress>
      Returns:
      The new instance.
    • newInstance

      public static AFTIPCSocket 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 AFTIPCSocket 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 AFTIPCSocket connectTo(AFTIPCSocketAddress addr) throws IOException
      Creates a new AFSocket and connects it to the given AFTIPCSocketAddress.
      Parameters:
      addr - The address to connect to.
      Returns:
      A new, connected socket.
      Throws:
      IOException - if the operation fails.
    • getChannel

      public AFTIPCSocketChannel getChannel()
      Overrides:
      getChannel in class AFSocket<AFTIPCSocketAddress>
    • main

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

      public AFTIPCErrInfo getErrInfo()
      Description copied from interface: AFTIPCSocketExtensions
      Returns the TIPC "ErrInfo" information from the ancillary receive buffer (if any was set), or null if no error was retrieved.
      Specified by:
      getErrInfo in interface AFTIPCSocketExtensions
      Returns:
      The ErrInfo.
    • getDestName

      public AFTIPCDestName getDestName()
      Description copied from interface: AFTIPCSocketExtensions
      Returns the TIPC "DestName" information from the ancillary receive buffer (if any was set), or null if no DestName was retrieved.
      Specified by:
      getDestName in interface AFTIPCSocketExtensions
      Returns:
      The service address or range (without scope) that was specified by the sender of the message.
    • getNodeIdentity

      public static byte[] getNodeIdentity(int peerId) throws IOException
      Retrieves the 16-byte node ID given a node hash.
      Parameters:
      peerId - The node hash.
      Returns:
      The node ID, or null if unsupported.
      Throws:
      IOException - on error.
    • getNodeIdentity

      public byte[] getNodeIdentity(AFTIPCSocketAddress address) throws IOException
      Retrieves the TIPC node identity given the node hash of the given address.
      Parameters:
      address - The address.
      Returns:
      The node identity, or null if unsupported.
      Throws:
      IOException - on error.
    • getNodeIdHexString

      public static String getNodeIdHexString(int peerId) throws IOException
      Retrieves the node ID given a node hash, as a hexadecimal string.
      Parameters:
      peerId - The node hash.
      Returns:
      The node ID, or null if unsupported.
      Throws:
      IOException - on error.
    • getLinkName

      public static String getLinkName(int peerId, int bearerId) throws IOException
      Retrieves the link name given a node hash and a bearer ID.
      Parameters:
      peerId - The node hash.
      bearerId - The bearer Id.
      Returns:
      The link name, or null if unsupported.
      Throws:
      IOException - on error.