org.minidns.record

## Class SRV

- java.lang.Object
- - org.minidns.record.Data
  - - org.minidns.record.SRV

- All Implemented Interfaces:
    Comparable<SRV>

      public class SRV
      extends Data
      implements Comparable<SRV>

  DNS SRV (Service) record payload for service discovery.
  Specifies the location of services for a given domain with priority, weight, and port information for load balancing.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `int` | `port` The target port.
    `int` | `priority` The priority of this service.
    `DnsName` | `target` The target server.
    `int` | `weight` The weight of this service.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SRV(int priority, int weight, int port, DnsName name)`
    `SRV(int priority, int weight, int port, String name)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `compareTo(SRV other)`
    `Record.TYPE` | `getType()` The payload type.
    `boolean` | `isServiceAvailable()` Check if the service is available at this domain.
    `static SRV` | `parse(DataInputStream dis, byte[] data)`
    `void` | `serialize(DataOutputStream dos)` The internal method used to serialize Data subclasses.
    `String` | `toString()`

    - ### Methods inherited from class org.minidns.record.Data

      `equals, hashCode, length, toByteArray, toOutputStream, toOutputStream`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### port

          public final int port

      The target port.

    - #### priority

          public final int priority

      The priority of this service. Lower values mean higher priority.

    - #### target

          public final DnsName target

      The target server.

    - #### weight

          public final int weight

      The weight of this service. Services with the same priority should be balanced based on weight.

  - ### Constructor Detail

    - #### SRV

          public SRV(int priority,
                     int weight,
                     int port,
                     DnsName name)

    - #### SRV

          public SRV(int priority,
                     int weight,
                     int port,
                     String name)

  - ### Method Detail

    - #### compareTo

          public int compareTo(SRV other)

      Specified by:
        `compareTo` in interface `Comparable<SRV>`

    - #### getType

          public Record.TYPE getType()

      Description copied from class: `Data`
      The payload type.
      Specified by:
        `getType` in class `Data`
      Returns:
        The payload type.

    - #### isServiceAvailable

          public boolean isServiceAvailable()

      Check if the service is available at this domain. This checks f the target points to the root label. As per RFC 2782 the service is decidedly not available if there is only a single SRV answer pointing to the root label. From RFC 2782:

      > A Target of "." means that the service is decidedly not available at this domain.

      Returns:
        true if the service is available at this domain.

    - #### parse

          public static SRV parse(DataInputStream dis,
                                  byte[] data)
                           throws IOException

      Throws:
        `IOException`

    - #### serialize

          public void serialize(DataOutputStream dos)
                         throws IOException

      Description copied from class: `Data`
      The internal method used to serialize Data subclasses.
      Specified by:
        `serialize` in class `Data`
      Parameters:
        `dos` - the output stream to serialize to.
      Throws:
        `IOException` - if an I/O error occurs.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`