Class SockAddrUnix

java.lang.Object
jnr.ffi.Struct
jnr.unixsocket.SockAddrUnix
Direct Known Subclasses:
SockAddrUnix.BSDSockAddrUnix, SockAddrUnix.DefaultSockAddrUnix

abstract class SockAddrUnix extends jnr.ffi.Struct
Native unix domain socket address structure.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    (package private) static final class 
    An implementation of SockAddrUnix for BSD systems
    (package private) static final class 
    An implementation of SockAddrUnix for Linux, Solaris, et, al

    Nested classes/interfaces inherited from class jnr.ffi.Struct

    jnr.ffi.Struct.AbstractBoolean, jnr.ffi.Struct.AbstractMember, jnr.ffi.Struct.Address, jnr.ffi.Struct.Alignment, jnr.ffi.Struct.AsciiString, jnr.ffi.Struct.AsciiStringRef, jnr.ffi.Struct.blkcnt_t, jnr.ffi.Struct.blksize_t, jnr.ffi.Struct.BOOL16, jnr.ffi.Struct.Boolean, jnr.ffi.Struct.BYTE, jnr.ffi.Struct.caddr_t, jnr.ffi.Struct.cc_t, jnr.ffi.Struct.clock_t, jnr.ffi.Struct.dev_t, jnr.ffi.Struct.Double, jnr.ffi.Struct.DWORD, jnr.ffi.Struct.Enum<T extends Enum<T>>, jnr.ffi.Struct.Enum16<E extends Enum<E>>, jnr.ffi.Struct.Enum32<E extends Enum<E>>, jnr.ffi.Struct.Enum64<E extends Enum<E>>, jnr.ffi.Struct.Enum8<E extends Enum<E>>, jnr.ffi.Struct.EnumField<E>, jnr.ffi.Struct.EnumLong<E extends Enum<E>>, jnr.ffi.Struct.Float, jnr.ffi.Struct.fsblkcnt_t, jnr.ffi.Struct.fsfilcnt_t, jnr.ffi.Struct.Function<T>, jnr.ffi.Struct.gid_t, jnr.ffi.Struct.id_t, jnr.ffi.Struct.in_addr_t, jnr.ffi.Struct.in_port_t, jnr.ffi.Struct.ino_t, jnr.ffi.Struct.ino64_t, jnr.ffi.Struct.int16_t, jnr.ffi.Struct.int32_t, jnr.ffi.Struct.int64_t, jnr.ffi.Struct.int8_t, jnr.ffi.Struct.IntegerAlias, jnr.ffi.Struct.intptr_t, jnr.ffi.Struct.key_t, jnr.ffi.Struct.LONG, jnr.ffi.Struct.Member, jnr.ffi.Struct.mode_t, jnr.ffi.Struct.nlink_t, jnr.ffi.Struct.NumberField, jnr.ffi.Struct.off_t, jnr.ffi.Struct.Offset, jnr.ffi.Struct.Padding, jnr.ffi.Struct.pid_t, jnr.ffi.Struct.Pointer, jnr.ffi.Struct.PointerField, jnr.ffi.Struct.rlim_t, jnr.ffi.Struct.sa_family_t, jnr.ffi.Struct.Signed16, jnr.ffi.Struct.Signed32, jnr.ffi.Struct.Signed64, jnr.ffi.Struct.Signed8, jnr.ffi.Struct.SignedLong, jnr.ffi.Struct.size_t, jnr.ffi.Struct.socklen_t, jnr.ffi.Struct.speed_t, jnr.ffi.Struct.ssize_t, jnr.ffi.Struct.String, jnr.ffi.Struct.StructRef<T extends jnr.ffi.Struct>, jnr.ffi.Struct.swblk_t, jnr.ffi.Struct.tcflag_t, jnr.ffi.Struct.time_t, jnr.ffi.Struct.u_int16_t, jnr.ffi.Struct.u_int32_t, jnr.ffi.Struct.u_int64_t, jnr.ffi.Struct.u_int8_t, jnr.ffi.Struct.uid_t, jnr.ffi.Struct.uintptr_t, jnr.ffi.Struct.Unsigned16, jnr.ffi.Struct.Unsigned32, jnr.ffi.Struct.Unsigned64, jnr.ffi.Struct.Unsigned8, jnr.ffi.Struct.UnsignedLong, jnr.ffi.Struct.UTF8String, jnr.ffi.Struct.UTF8StringRef, jnr.ffi.Struct.UTFString, jnr.ffi.Struct.UTFStringRef, jnr.ffi.Struct.WBOOL, jnr.ffi.Struct.WORD
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    private String
     
    private static jnr.ffi.Platform.OS
     
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) static SockAddrUnix
    Creates a new instance of SockAddrUnix
    (package private) final jnr.constants.platform.ProtocolFamily
    Gets the protocol family of this unix socket address.
    protected abstract jnr.ffi.Struct.NumberField
     
    (package private) int
    Gets len/family header length
    (package private) int
    Gets the maximum length of this address (including len/family header)
    (package private) final String
    Gets the file system path of this socket address
    (package private) final String
    getPath(int len)
    Gets the path of this socket address, supporting abstract namespace on Linux.
    protected abstract jnr.ffi.Struct.UTF8String
     
    (package private) int
    Gets the actual length of this address (including len/family header)
    (package private) final void
    setFamily(jnr.constants.platform.ProtocolFamily family)
    Sets the protocol family of this unix socket address.
    (package private) void
    Sets the file system path of this socket address
    private static final int
    strlen(jnr.ffi.Struct.UTF8String str)
     
    (package private) void
    updatePath(int len)
    Updates the file system path of this socket address.

    Methods inherited from class jnr.ffi.Struct

    alignment, array, array, array, array, array, array, array, array, array, array, array, array, array, array, array, array, array, array, array, array, array, arrayBegin, arrayEnd, arrayOf, function, getMemory, getMemory, getRuntime, inner, inner, isDirect, size, size, size, toString, useMemory

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • currentOS

      private static transient jnr.ffi.Platform.OS currentOS
    • ADDR_LENGTH

      public static final int ADDR_LENGTH
      See Also:
    • HEADER_LENGTH

      public static final int HEADER_LENGTH
      See Also:
    • cachedPath

      private String cachedPath
  • Constructor Details

    • SockAddrUnix

      SockAddrUnix()
  • Method Details

    • getPathField

      protected abstract jnr.ffi.Struct.UTF8String getPathField()
    • getFamilyField

      protected abstract jnr.ffi.Struct.NumberField getFamilyField()
    • setFamily

      final void setFamily(jnr.constants.platform.ProtocolFamily family)
      Sets the protocol family of this unix socket address.
      Parameters:
      family - The protocol family, usually ProtocolFamily.PF_UNIX
    • getFamily

      final jnr.constants.platform.ProtocolFamily getFamily()
      Gets the protocol family of this unix socket address.
      Returns:
      The protocol family
    • setPath

      void setPath(String path)
      Sets the file system path of this socket address
      Parameters:
      path - The unix socket address
    • updatePath

      void updatePath(int len)
      Updates the file system path of this socket address. In order to support abstract namespaces, this MUST be called after any native syscall that sets this path struct like getsockname(), getpeername(), accept().
      Parameters:
      len - the value of the addrlen var, set by the above syscalls.
    • getPath

      final String getPath()
      Gets the file system path of this socket address
      Returns:
      A String
    • getPath

      final String getPath(int len)
      Gets the path of this socket address, supporting abstract namespace on Linux.
      Parameters:
      len - The desired length of the string. If the first character of the path is NUL, then this value ist considered exact, otherwise it includes a trailing NUL charater and therefore the actual string length is len - 1.
    • getMaximumLength

      int getMaximumLength()
      Gets the maximum length of this address (including len/family header)
      Returns:
      The maximum size of the address in bytes
    • length

      int length()
      Gets the actual length of this address (including len/family header)
      Returns:
      The actual size of this address, in bytes
    • getHeaderLength

      int getHeaderLength()
      Gets len/family header length
      Returns:
      The size of header, in bytes
    • create

      static SockAddrUnix create()
      Creates a new instance of SockAddrUnix
      Returns:
      An instance of SockAddrUnix
    • strlen

      private static final int strlen(jnr.ffi.Struct.UTF8String str)