Package jnr.netdb

Class Service

java.lang.Object
jnr.netdb.Service

public final class Service extends Object
Holds information about TCP and UDP services on a host.
  • Field Details

    • serviceName

      private final String serviceName
      Official service name
    • port

      private final int port
      TCP or UDP port number
    • proto

      final String proto
      Protocol to use
    • aliases

      private final Collection<String> aliases
      All the aliases for this service
  • Constructor Details

  • Method Details

    • getServiceByName

      public static final Service getServiceByName(String name, String proto)
      Locates a service by name and protocol.
      Parameters:
      name - the official IANA name for the service, or an alias.
      proto - the protocol for the service. Usually "tcp" or "udp".
      Returns:
      a Service instance, or null if the service could not be found.
    • getServiceByPort

      public static final Service getServiceByPort(int port, String proto)
      Locates a service by port and protocol.
      Parameters:
      port - the TCP or UDP port of the service.
      proto - the protocol for the service. Usually "tcp" or "udp".
      Returns:
      a Service instance, or null if the service could not be found.
    • getAllServices

      public static final Collection<Service> getAllServices()
      Returns a list of all services.
      Returns:
      a Collection of Service instances.
    • getName

      public final String getName()
      Returns the official IANA name of this Service
      Returns:
      The name of this Service as a String
    • getPort

      public final int getPort()
      Returns the official IANA port for this Service
      Returns:
      The port for this Service as an int
    • getAliases

      public final Collection<String> getAliases()
      Gets a list of aliases this Service is also known as.
      Returns:
      A Collection of Strings for aliases this Service
    • getServicesDB

      private static final ServicesDB getServicesDB()
      Returns the currently loaded ServicesDB
      Returns:
      an instance of ServicesDB
    • toString

      public String toString()
      Overrides:
      toString in class Object