Class Sockaddr

  • All Implemented Interfaces:
    java.lang.AutoCloseable, org.lwjgl.system.NativeResource, org.lwjgl.system.Pointer

    public class Sockaddr
    extends org.lwjgl.system.Struct
    implements org.lwjgl.system.NativeResource
    Structure describing a generic socket address.

    Layout

    
     struct sockaddr {
         sa_family_t sa_family();
         char sa_data()[14];
     }
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Sockaddr.Buffer
      An array of Sockaddr structs.
      • Nested classes/interfaces inherited from interface org.lwjgl.system.Pointer

        org.lwjgl.system.Pointer.Default
      • Nested classes/interfaces inherited from class org.lwjgl.system.Struct

        org.lwjgl.system.Struct.StructValidation
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int ALIGNOF
      The struct alignment in bytes.
      static int SA_DATA
      SA_FAMILY
      The struct member offsets.
      static int SIZEOF
      The struct size in bytes.
      • Fields inherited from interface org.lwjgl.system.Pointer

        BITS32, BITS64, CLONG_SHIFT, CLONG_SIZE, POINTER_SHIFT, POINTER_SIZE
    • Constructor Summary

      Constructors 
      Constructor Description
      Sockaddr​(java.nio.ByteBuffer container)
      Creates a Sockaddr instance at the current position of the specified ByteBuffer container.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static Sockaddr calloc()
      Returns a new Sockaddr instance allocated with memCalloc.
      static Sockaddr.Buffer calloc​(int capacity)
      Returns a new Sockaddr.Buffer instance allocated with memCalloc.
      static Sockaddr.Buffer calloc​(int capacity, org.lwjgl.system.MemoryStack stack)
      Returns a new Sockaddr.Buffer instance allocated on the specified MemoryStack and initializes all its bits to zero.
      static Sockaddr calloc​(org.lwjgl.system.MemoryStack stack)
      Returns a new Sockaddr instance allocated on the specified MemoryStack and initializes all its bits to zero.
      static Sockaddr create()
      Returns a new Sockaddr instance allocated with BufferUtils.
      static Sockaddr.Buffer create​(int capacity)
      Returns a new Sockaddr.Buffer instance allocated with BufferUtils.
      static Sockaddr create​(long address)
      Returns a new Sockaddr instance for the specified memory address.
      static Sockaddr.Buffer create​(long address, int capacity)
      Create a Sockaddr.Buffer instance at the specified memory.
      static Sockaddr createSafe​(long address)
      Like create, but returns null if address is NULL.
      static Sockaddr.Buffer createSafe​(long address, int capacity)
      Like create, but returns null if address is NULL.
      static Sockaddr malloc()
      Returns a new Sockaddr instance allocated with memAlloc.
      static Sockaddr.Buffer malloc​(int capacity)
      Returns a new Sockaddr.Buffer instance allocated with memAlloc.
      static Sockaddr.Buffer malloc​(int capacity, org.lwjgl.system.MemoryStack stack)
      Returns a new Sockaddr.Buffer instance allocated on the specified MemoryStack.
      static Sockaddr malloc​(org.lwjgl.system.MemoryStack stack)
      Returns a new Sockaddr instance allocated on the specified MemoryStack.
      static java.nio.ByteBuffer nsa_data​(long struct)
      Unsafe version of sa_data().
      static byte nsa_data​(long struct, int index)
      Unsafe version of sa_data.
      static void nsa_data​(long struct, int index, byte value)
      Unsafe version of sa_data.
      static void nsa_data​(long struct, java.nio.ByteBuffer value)
      Unsafe version of sa_data.
      static short nsa_family​(long struct)
      Unsafe version of sa_family().
      static void nsa_family​(long struct, short value)
      Unsafe version of sa_family.
      java.nio.ByteBuffer sa_data()
      address data
      byte sa_data​(int index)
      address data
      Sockaddr sa_data​(int index, byte value)
      Sets the specified value at the specified index of the sa_data() field.
      Sockaddr sa_data​(java.nio.ByteBuffer value)
      Copies the specified ByteBuffer to the sa_data() field.
      short sa_family()
      address family and length
      Sockaddr sa_family​(short value)
      Sets the specified value to the sa_family() field.
      Sockaddr set​(short sa_family, java.nio.ByteBuffer sa_data)
      Initializes this struct with the specified values.
      Sockaddr set​(Sockaddr src)
      Copies the specified struct data to this struct.
      int sizeof()  
      • Methods inherited from interface org.lwjgl.system.NativeResource

        close, free
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from class org.lwjgl.system.Pointer.Default

        address, equals, hashCode, toString
      • Methods inherited from class org.lwjgl.system.Struct

        clear, free, isNull, validate
    • Field Detail

      • SIZEOF

        The struct size in bytes.
      • ALIGNOF

        The struct alignment in bytes.
      • SA_FAMILY, SA_DATA

        The struct member offsets.
    • Constructor Detail

      • Sockaddr

        public Sockaddr​(java.nio.ByteBuffer container)
        Creates a Sockaddr instance at the current position of the specified ByteBuffer container. Changes to the buffer's content will be visible to the struct instance and vice versa.

        The created instance holds a strong reference to the container object.

    • Method Detail

      • sizeof

        public int sizeof()
        Specified by:
        sizeof in class org.lwjgl.system.Struct
      • sa_family

        public short sa_family()
        address family and length
      • sa_data

        public java.nio.ByteBuffer sa_data()
        
        public byte sa_data​(int index)
        
        address data
      • sa_family

        public Sockaddr sa_family​(short value)
        Sets the specified value to the sa_family() field.
      • sa_data

        public Sockaddr sa_data​(java.nio.ByteBuffer value)
        Copies the specified ByteBuffer to the sa_data() field.
      • sa_data

        public Sockaddr sa_data​(int index,
                                byte value)
        Sets the specified value at the specified index of the sa_data() field.
      • set

        public Sockaddr set​(short sa_family,
                            java.nio.ByteBuffer sa_data)
        Initializes this struct with the specified values.
      • set

        public Sockaddr set​(Sockaddr src)
        Copies the specified struct data to this struct.
        Parameters:
        src - the source struct
        Returns:
        this struct
      • malloc

        public static Sockaddr malloc()
        Returns a new Sockaddr instance allocated with memAlloc. The instance must be explicitly freed.
      • calloc

        public static Sockaddr calloc()
        Returns a new Sockaddr instance allocated with memCalloc. The instance must be explicitly freed.
      • create

        public static Sockaddr create()
        Returns a new Sockaddr instance allocated with BufferUtils.
      • create

        public static Sockaddr create​(long address)
        Returns a new Sockaddr instance for the specified memory address.
      • createSafe

        @Nullable
        public static Sockaddr createSafe​(long address)
        Like create, but returns null if address is NULL.
      • malloc

        public static Sockaddr.Buffer malloc​(int capacity)
        Returns a new Sockaddr.Buffer instance allocated with memAlloc. The instance must be explicitly freed.
        Parameters:
        capacity - the buffer capacity
      • calloc

        public static Sockaddr.Buffer calloc​(int capacity)
        Returns a new Sockaddr.Buffer instance allocated with memCalloc. The instance must be explicitly freed.
        Parameters:
        capacity - the buffer capacity
      • create

        public static Sockaddr.Buffer create​(int capacity)
        Returns a new Sockaddr.Buffer instance allocated with BufferUtils.
        Parameters:
        capacity - the buffer capacity
      • create

        public static Sockaddr.Buffer create​(long address,
                                             int capacity)
        Create a Sockaddr.Buffer instance at the specified memory.
        Parameters:
        address - the memory address
        capacity - the buffer capacity
      • createSafe

        @Nullable
        public static Sockaddr.Buffer createSafe​(long address,
                                                 int capacity)
        Like create, but returns null if address is NULL.
      • malloc

        public static Sockaddr malloc​(org.lwjgl.system.MemoryStack stack)
        Returns a new Sockaddr instance allocated on the specified MemoryStack.
        Parameters:
        stack - the stack from which to allocate
      • calloc

        public static Sockaddr calloc​(org.lwjgl.system.MemoryStack stack)
        Returns a new Sockaddr instance allocated on the specified MemoryStack and initializes all its bits to zero.
        Parameters:
        stack - the stack from which to allocate
      • malloc

        public static Sockaddr.Buffer malloc​(int capacity,
                                             org.lwjgl.system.MemoryStack stack)
        Returns a new Sockaddr.Buffer instance allocated on the specified MemoryStack.
        Parameters:
        stack - the stack from which to allocate
        capacity - the buffer capacity
      • calloc

        public static Sockaddr.Buffer calloc​(int capacity,
                                             org.lwjgl.system.MemoryStack stack)
        Returns a new Sockaddr.Buffer instance allocated on the specified MemoryStack and initializes all its bits to zero.
        Parameters:
        stack - the stack from which to allocate
        capacity - the buffer capacity
      • nsa_family

        public static short nsa_family​(long struct)
        Unsafe version of sa_family().
      • nsa_data

        public static java.nio.ByteBuffer nsa_data​(long struct)
        Unsafe version of sa_data().
      • nsa_data

        public static byte nsa_data​(long struct,
                                    int index)
        Unsafe version of sa_data.
      • nsa_family

        public static void nsa_family​(long struct,
                                      short value)
        Unsafe version of sa_family.
      • nsa_data

        public static void nsa_data​(long struct,
                                    java.nio.ByteBuffer value)
        Unsafe version of sa_data.
      • nsa_data

        public static void nsa_data​(long struct,
                                    int index,
                                    byte value)
        Unsafe version of sa_data.