Methods in CoAP
CoAP is a web-based protocol. This means CoAP resembles the HTTP protocol and is capable to utilize the HTTP methods.
These methods are-
- GET – The get method is used to retrieve resource information identified by the request URI. In response to GET method success a 200(OK) response is sent.
- POST – The post method creates a new subordinate resource under the parent URI requested by it to the server. On successful resource creation on the server, a 201 (Created) response is sent while on failure a 200 (OK) response code is sent.
- DELETE – The delete method deletes the resource identified by the requested URI and a 200 (OK) response code is sent on successful operation.
- PUT – The PUT method updates or creates the resource identified by the request URI with the enclosed message body. The message body is considered as modified version of a resource if it already exists at the specified URI otherwise a new resource with that URI is created. A 200 (OK) response is received in former case whereas a 201 (Created) response is received in later case. If the resource is neither created nor modified then an error response code is sent.
The most fundamental difference between CoAP and HTTP is that CoAP defines a new method which is not present in HTTP. This method is called Observe method.
The observe method is very similar to the GET method in addition with an observe option. This alerts the server, to send every update about the resource to the client. Therefore, upon any change in the resource, the server sends a response to the client.
These responses could either be directly sent individually or they can be piggy-backed.
Constrained Application Protocol (CoAP)
There are several protocols in the application layer of the Internet protocol suite. One such useful protocol is the CoAP or Constrained Application Protocol. This protocol has a wide range of advantages and applications in the field of the Internet of Things (IoT) and cloud computing. CoAP also has a powerful contribution in providing versatile solutions to IoT applications.
This article delves into a set of key topics and fundamental concepts in CoAP protocol along with its applications in the real world.
Contact Us