Class TcpConnection

All Implemented Interfaces:
AutoCloseable, Proxy, AutoCloseable
Direct Known Subclasses:
TcpWrapperConnection

@Generated("org.javagi.JavaGI") public class TcpConnection extends SocketConnection
This is the subclass of SocketConnection that is created for TCP/IP sockets.
Since:
2.22
  • Constructor Details

    • TcpConnection

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

      public TcpConnection()
      Create a new TcpConnection.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the TcpConnection class.
      Returns:
      the GType
    • getMemoryLayout

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

      protected TcpConnection asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class SocketConnection
      Returns:
      the instance as if it were its parent type
    • getGracefulDisconnect

      public boolean getGracefulDisconnect()
      Checks if graceful disconnects are used. See g_tcp_connection_set_graceful_disconnect().
      Returns:
      true if graceful disconnect is used on close, false otherwise
      Since:
      2.22
    • setGracefulDisconnect

      public void setGracefulDisconnect(boolean gracefulDisconnect)

      This enables graceful disconnects on close. A graceful disconnect means that we signal the receiving end that the connection is terminated and wait for it to close the connection before closing the connection.

      A graceful disconnect means that we can be sure that we successfully sent all the outstanding data to the other end, or get an error reported. However, it also means we have to wait for all the data to reach the other side and for it to acknowledge this by closing the socket, which may take a while. For this reason it is disabled by default.

      Parameters:
      gracefulDisconnect - Whether to do graceful disconnects or not
      Since:
      2.22
    • builder

      public static TcpConnection.Builder<? extends TcpConnection.Builder> builder()
      A TcpConnection.Builder object constructs a TcpConnection with the specified properties. Use the various set...() methods to set properties, and finish construction with TcpConnection.Builder.build().
      Returns:
      the builder object