Skip to content

Latest commit

 

History

History
74 lines (46 loc) · 3.54 KB

README.md

File metadata and controls

74 lines (46 loc) · 3.54 KB

TCP - Implementation of CoAP TCP connector in C#

NuGet Status Build Status Appveyor Build CircleCI

The Constrained Application Protocol (CoAP) (https://datatracker.ietf.org/doc/draft-ietf-core-coap/) is a RESTful web transfer protocol for resource-constrained networks and nodes. CoAP.NET is an implementation in C# providing CoAP-based services to .NET applications.

The base specification uses UDP as the transport for sending messages. CoAP-TCP provides a definition of how to use TCP with or without TLS as a transport protocol. The use of TLS allows for reliable transport which can be advantagous in some circumstances, although with a corresponding increase in the code footprint and network traffic.

This project provides an implementation of the TCP and TLS connectors that can be used with the CoAP.NET implementation.

Reviews and suggestions would be appreciated.

Copyright

Copyright (c) 2017-9, Jim Schaad [email protected]

Content

How to Install

The C# implementation is available in the NuGet Package Gallery under the name Com.AugustCellars.CoAP.TLS. To install this library as a NuGet package, enter 'Install-Package Com.AugustCellars.CoAP.TLS' in the NuGet Package Manager Console.

Documentation

Documentation can be found in two places. First an XML file is installed as part of the package for inline documentation. At some point, the Wiki associated with this project.

Quick Start

CoAP Client

To use the TCP or TLS endpoint from a client, one starts by creating and starting the desired endpoint and then associating it with a request. The same endpoint can be used with multiple requests and target addresses.

  // Create the endpoint
  CoapEndpoint ep = new TcpEndpoint();
  ep.Start();

  Request request = new Request(Method.GET);
  request.URI = new Uri("coap://[::1]/hello-world");
  request.EndPoint = ep;
  request.Send();

  //  Wait for one response
  Response response = request.WaitForResponse();

The endpoint MUST be started before it can be used, this is not done automatically. The endpoint SHOULD be stopped before it is disposed of, but that will happen eventially even if it is not marked as such. However the TCP connection will not be closed until the endpoint is stopped.

CoAP Server

A TCP endpoint is added to a CoAP server object in a similar manner. As long as the endpoint is added to the server before it is started, then starting the endpoint is optional. Similarly the endpoint will be shutdown when the server is stopped.

Building the sources

I am currently sync-ed up to Visual Studio 2019 and have started using language features of C# v7.0 that are supported both in Visual Studio and in the latest version of mono.

License

See LICENSE for more info.