Class Sockaddr

java.lang.Object
org.lwjgl.system.Pointer.Default
org.lwjgl.system.Struct<Sockaddr>
org.lwjgl.system.linux.Sockaddr
All Implemented Interfaces:
AutoCloseable, org.lwjgl.system.NativeResource, org.lwjgl.system.Pointer

public class Sockaddr extends org.lwjgl.system.Struct<Sockaddr> 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 
    An array of Sockaddr structs.

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

    org.lwjgl.system.Struct.StructValidation

    Nested classes/interfaces inherited from interface org.lwjgl.system.Pointer

    org.lwjgl.system.Pointer.Default
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The struct alignment in bytes.
    static final int
    The struct member offsets.
    static final int
    The struct member offsets.
    static final int
    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(ByteBuffer container)
    Creates a Sockaddr instance at the current position of the specified ByteBuffer container.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Sockaddr
    Returns a new Sockaddr instance allocated with memCalloc.
    calloc(int capacity)
    Returns a new Sockaddr.Buffer instance allocated with memCalloc.
    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
    Returns a new Sockaddr instance allocated with BufferUtils.
    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.
    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.
    createSafe(long address, int capacity)
    Like create, but returns null if address is NULL.
    static Sockaddr
    Returns a new Sockaddr instance allocated with memAlloc.
    malloc(int capacity)
    Returns a new Sockaddr.Buffer instance allocated with memAlloc.
    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 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, 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.
    address data
    byte
    sa_data(int index)
    address data
    sa_data(int index, byte value)
    Sets the specified value at the specified index of the sa_data() field.
    Copies the specified ByteBuffer to the sa_data() field.
    short
    address family and length
    sa_family(short value)
    Sets the specified value to the sa_family() field.
    set(short sa_family, ByteBuffer sa_data)
    Initializes this struct with the specified values.
    Copies the specified struct data to this struct.
    int
     

    Methods inherited from class org.lwjgl.system.Struct

    clear, free, isNull, validate

    Methods inherited from class org.lwjgl.system.Pointer.Default

    address, equals, hashCode, toString

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.lwjgl.system.NativeResource

    close, free
  • Field Details

    • SIZEOF

      public static final int SIZEOF
      The struct size in bytes.
    • ALIGNOF

      public static final int ALIGNOF
      The struct alignment in bytes.
    • SA_FAMILY

      public static final int SA_FAMILY
      The struct member offsets.
    • SA_DATA

      public static final int SA_DATA
      The struct member offsets.
  • Constructor Details

    • Sockaddr

      public Sockaddr(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 Details

    • sizeof

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

      public short sa_family()
      address family and length
    • sa_data

      public ByteBuffer sa_data()
      address data
    • 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(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, 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:
      capacity - the buffer capacity
      stack - the stack from which to allocate
    • 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:
      capacity - the buffer capacity
      stack - the stack from which to allocate
    • nsa_family

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

      public static 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, 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.