7. Discovery
7.1. Service Discovery
As part of discovering the services offered by a CoAP server, a client must learn about the endpoint used by a server.
A client might discover a server by (knowing about or) learning a URI that references a resource in the namespace of the server. Alternatively, a client could use multicast CoAP (see Section 8) and the "All CoAP Nodes" multicast address to find CoAP servers.
Unless the port subcomponent in a "coap" or "coaps" URI indicates the UDP port at which the CoAP server is located, the server is assumed to be reachable at the default port.
A server that offers resource discovery services MUST support the CoAP default port number 5683 (for resource discovery and for the resources it provides access to), and SHOULD support the default port number 5684 for DTLS-secured CoAP. In addition, other endpoints may be hosted at other ports, for example in the dynamic port space.
Implementation Note: When a CoAP server is hosted by a 6LoWPAN node, header compression efficiency is improved when it also supports a port number in the compressed UDP port space defined in [RFC4944] and [RFC6282] in the range 61616-61631. (Note that, as its UDP port differs from the default port, it is a different endpoint from a server at the default port.)
7.2. Resource Discovery
The discovery of resources offered by a CoAP endpoint is extremely important in machine-to-machine applications where there are no humans in the loop and static interfaces result in fragility. To maximize interoperability in a CoRE environment, a CoAP endpoint SHOULD support the CoRE Link Format of discoverable resources as described in [RFC6690] and make that available at the default discovery path "/.well-known/core". Likewise, hosts should offer Web Linking [RFC5988] on their HTTP servers and make that available at the same default discovery path, unless manual configuration is desired. It is up to the server which resources are made discoverable (if any).
7.2.1. 'ct' Attribute
This section defines a new Web Linking [RFC5988] attribute for use with [RFC6690]. The Content-Format code "ct" attribute provides a hint about the Content-Formats this resource returns. Note that this is only a hint, and it does not override the Content-Format Option of a CoAP response obtained by actually requesting the representation of the resource. The value is in the CoAP identifier code format as a decimal ASCII integer and MUST be in the range 0-65535 (16-bit unsigned integer). For example, "application/xml" would be indicated as "ct=41". If no Content-Format code attribute is present then nothing about the type can be assumed. The Content-Format code attribute MAY include a space-separated sequence of Content-Format codes, indicating that multiple Content-Formats are available. The syntax of the attribute value is summarized in the production "ct-value" in Figure 12, where the definitions of "cardinal", "SP", and "DQUOTE" are as in [RFC6690].
ct-value = cardinal
/ DQUOTE cardinal *( 1*SP cardinal ) DQUOTE
Figure 12