Class InetSocketAddress

All Implemented Interfaces:
SocketConnectable, Proxy
Direct Known Subclasses:
ProxyAddress

@Generated("org.javagi.JavaGI") public class InetSocketAddress extends SocketAddress implements SocketConnectable

An IPv4 or IPv6 socket address. That is, the combination of a InetAddress and a port number.

In UNIX terms, GInetSocketAddress corresponds to a struct sockaddr_in or struct sockaddr_in6.

  • Constructor Details

    • InetSocketAddress

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

      public InetSocketAddress(InetAddress address, short port)
      Creates a new GInetSocketAddress for address and port.
      Parameters:
      address - a GInetAddress
      port - a port number
      Since:
      2.22
    • InetSocketAddress

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

    • getType

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

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

      protected InetSocketAddress 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 SocketAddress
      Returns:
      the instance as if it were its parent type
    • fromString

      public static @Nullable SocketAddress fromString(String address, int port)

      Creates a new GInetSocketAddress for address and port.

      If address is an IPv6 address, it can also contain a scope ID (separated from the address by a %). Note that currently this behavior is platform specific. This may change in a future release.

      Parameters:
      address - the string form of an IP address
      port - a port number
      Returns:
      a new GInetSocketAddress, or null if address cannot be parsed.
      Since:
      2.40
    • getAddress

      public InetAddress getAddress()
      Gets address's GInetAddress.
      Returns:
      the GInetAddress for address, which must be g_object_ref()'d if it will be stored
      Since:
      2.22
    • getFlowinfo

      public int getFlowinfo()

      Gets the sin6_flowinfo field from address, which must be an IPv6 address.

      If not overridden this value will be inherited from Gio.InetSocketAddress:address.

      Returns:
      the flowinfo field
      Since:
      2.32
    • getPort

      public short getPort()
      Gets address's port.
      Returns:
      the port for this InetSocketAddress
      Since:
      2.22
    • getScopeId

      public int getScopeId()

      Gets the sin6_scope_id field from address, which must be an IPv6 address.

      If not overridden this value will be inherited from Gio.InetSocketAddress:address.

      Returns:
      the scope id field
      Since:
      2.32
    • builder

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