Class InputMessage

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class InputMessage extends ProxyInstance

Structure used for scatter/gather data input when receiving multiple messages or packets in one go. You generally pass in an array of empty GInputVectors and the operation will use all the buffers as if they were one buffer, and will set bytesReceived to the total number of bytes received across all GInputVectors.

This structure closely mirrors struct mmsghdr and struct msghdr from the POSIX sockets API (see man 2 recvmmsg).

If address is non-null then it is set to the source address the message was received from, and the caller must free it afterwards.

If controlMessages is non-null then it is set to an array of control messages received with the message (if any), and the caller must free it afterwards. numControlMessages is set to the number of elements in this array, which may be zero.

Flags relevant to this message will be returned in flags. For example, MSG_EOR or MSG_TRUNC.

Since:
2.48
  • Constructor Details

    • InputMessage

      public InputMessage(MemorySegment address)
      Create a InputMessage proxy instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • InputMessage

      public InputMessage(Arena arena)
      Allocate a new InputMessage.
      Parameters:
      arena - to control the memory allocation scope
    • InputMessage

      public InputMessage()
      Allocate a new InputMessage. The memory is allocated with Arena.ofAuto().
    • InputMessage

      public InputMessage(SocketAddress[] address, InputVector[] vectors, int numVectors, long bytesReceived, int flags, SocketControlMessage[] controlMessages, MemorySegment numControlMessages, Arena arena)
      Allocate a new InputMessage with the fields set to the provided values.
      Parameters:
      address - value for the field address
      vectors - value for the field vectors
      numVectors - value for the field numVectors
      bytesReceived - value for the field bytesReceived
      flags - value for the field flags
      controlMessages - value for the field controlMessages
      numControlMessages - value for the field numControlMessages
      arena - to control the memory allocation scope
    • InputMessage

      public InputMessage(SocketAddress[] address, InputVector[] vectors, int numVectors, long bytesReceived, int flags, SocketControlMessage[] controlMessages, MemorySegment numControlMessages)
      Allocate a new InputMessage with the fields set to the provided values. The memory is allocated with Arena.ofAuto().
      Parameters:
      address - value for the field address
      vectors - value for the field vectors
      numVectors - value for the field numVectors
      bytesReceived - value for the field bytesReceived
      flags - value for the field flags
      controlMessages - value for the field controlMessages
      numControlMessages - value for the field numControlMessages
  • Method Details

    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • readAddress

      public SocketAddress[] readAddress(int length)
      Read the value of the field address.
      Parameters:
      length - the number of address to read
      Returns:
      The value of the field address
    • writeAddress

      public void writeAddress(SocketAddress[] address, Arena _arena)
      Write a value in the field address.
      Parameters:
      address - The new value for the field address
      _arena - to control the memory allocation scope
    • readVectors

      public @Nullable InputVector @Nullable [] readVectors()
      Read the value of the field vectors.
      Returns:
      The value of the field vectors
    • writeVectors

      public void writeVectors(@Nullable InputVector @Nullable [] vectors, Arena _arena)
      Write a value in the field vectors.
      Parameters:
      vectors - The new value for the field vectors
      _arena - to control the memory allocation scope
    • readNumVectors

      public int readNumVectors()
      Read the value of the field num_vectors.
      Returns:
      The value of the field num_vectors
    • writeNumVectors

      public void writeNumVectors(int numVectors)
      Write a value in the field num_vectors.
      Parameters:
      numVectors - The new value for the field num_vectors
    • readBytesReceived

      public long readBytesReceived()
      Read the value of the field bytes_received.
      Returns:
      The value of the field bytes_received
    • writeBytesReceived

      public void writeBytesReceived(long bytesReceived)
      Write a value in the field bytes_received.
      Parameters:
      bytesReceived - The new value for the field bytes_received
    • readFlags

      public int readFlags()
      Read the value of the field flags.
      Returns:
      The value of the field flags
    • writeFlags

      public void writeFlags(int flags)
      Write a value in the field flags.
      Parameters:
      flags - The new value for the field flags
    • readControlMessages

      public @Nullable SocketControlMessage @Nullable [] readControlMessages()
      Read the value of the field control_messages.
      Returns:
      The value of the field control_messages
    • writeControlMessages

      public void writeControlMessages(@Nullable SocketControlMessage @Nullable [] controlMessages, Arena _arena)
      Write a value in the field control_messages.
      Parameters:
      controlMessages - The new value for the field control_messages
      _arena - to control the memory allocation scope
    • readNumControlMessages

      public MemorySegment readNumControlMessages()
      Read the value of the field num_control_messages.
      Returns:
      The value of the field num_control_messages
    • writeNumControlMessages

      public void writeNumControlMessages(MemorySegment numControlMessages)
      Write a value in the field num_control_messages.
      Parameters:
      numControlMessages - The new value for the field num_control_messages