6. Usage Rules
6.1 Client Processing Procedure
A SRV-cognizant client SHOULD use this procedure to locate a list of servers and connect to the preferred one:
6.2 Algorithm Steps
Step 1: Perform SRV Query
Do a lookup for:
QNAME=_service._protocol.target
QCLASS=IN
QTYPE=SRV
Step 2: Check Response
If the reply is NOERROR, ANCOUNT>0 and there is at least one SRV RR which specifies the requested Service and Protocol in the reply:
Step 3: Check for Service Unavailability
If there is precisely one SRV RR, and its Target is "." (the root domain), abort.
Step 4: Build Candidate List
Else, for all such RR's, build a list of (Priority, Weight, Target) tuples.
Step 5: Sort by Priority
Sort the list by priority (lowest number first).
Step 6: Create Ordered List
Create a new empty list.
For each distinct priority level:
- While there are still elements left at this priority level
- Select an element as specified above, in the description of Weight in "The format of the SRV RR" Section, and move it to the tail of the new list
Step 7: Query and Connect
For each element in the new list:
- Query the DNS for address records for the Target or use any such records found in the Additional Data section of the earlier SRV response
- For each address record found, try to connect to the
(protocol, address, service)
Step 8: Fallback to A Record
Else (if no SRV records):
Do a lookup for:
QNAME=target
QCLASS=IN
QTYPE=A
For each address record found, try to connect to the (protocol, address, service).
6.3 Important Notes
6.3.1 Port Numbers
Port numbers SHOULD NOT be used in place of the symbolic service or protocol names (for the same reason why variant names cannot be allowed: Applications would have to do two or more lookups).
6.3.2 Truncated Responses
If a truncated response comes back from an SRV query, the rules described in [RFC 2181] shall apply.
6.3.3 Parsing Requirements
A client MUST parse all of the RR's in the reply.
6.3.4 Additional Data Section
If the Additional Data section doesn't contain address records for all the SRV RR's and the client may want to connect to the target host(s) involved, the client MUST look up the address record(s).
This happens quite often when the address record has shorter TTL than the SRV or NS RR's.
6.3.5 Future Protocols
Future protocols could be designed to use SRV RR lookups as the means by which clients locate their servers.
Navigation
- Previous: 5. The Port Number
- Next: 7. Fictional Example