Class NetworkService

All Implemented Interfaces:
SocketConnectable, Proxy

@Generated("org.javagi.JavaGI") public class NetworkService extends GObject implements SocketConnectable

Like NetworkAddress does with hostnames, GNetworkService provides an easy way to resolve a SRV record, and then attempt to connect to one of the hosts that implements that service, handling service priority/weighting, multiple IP addresses, and multiple address families.

See Gio.SrvTarget for more information about SRV records, and see SocketConnectable for an example of using the connectable interface.

  • Constructor Details

    • NetworkService

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

      public NetworkService(String service, String protocol, String domain)
      Creates a new GNetworkService representing the given service, protocol, and domain. This will initially be unresolved; use the GSocketConnectable interface to resolve it.
      Parameters:
      service - the service type to look up (eg, "ldap")
      protocol - the networking protocol to use for service (eg, "tcp")
      domain - the DNS domain to look up the service in
      Since:
      2.22
    • NetworkService

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

    • getType

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

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

      protected NetworkService 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 GObject
      Returns:
      the instance as if it were its parent type
    • getDomain

      public String getDomain()
      Gets the domain that this NetworkService serves. This might be either UTF-8 or ASCII-encoded, depending on what this NetworkService was created with.
      Returns:
      srv's domain name
      Since:
      2.22
    • getProtocol

      public String getProtocol()
      Gets srv's protocol name (eg, "tcp").
      Returns:
      srv's protocol name
      Since:
      2.22
    • getScheme

      public String getScheme()
      Gets the URI scheme used to resolve proxies. By default, the service name is used as scheme.
      Returns:
      srv's scheme name
      Since:
      2.26
    • getService

      public String getService()
      Gets srv's service name (eg, "ldap").
      Returns:
      srv's service name
      Since:
      2.22
    • setScheme

      public void setScheme(String scheme)
      Set's the URI scheme used to resolve proxies. By default, the service name is used as scheme.
      Parameters:
      scheme - a URI scheme
      Since:
      2.26
    • builder

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