aiocoap.transports.simplesocketserver module

This module implements a MessageInterface for UDP based on the asyncio DatagramProtocol.

This is a simple version that works only for servers bound to a single unicast address. It provides a server backend in situations when udp6 is unavailable and simple6 needs to be used for clients.

While it is in theory capable of sending requests too, it should not be used like that, because it won’t receive ICMP errors (see below).


  • This implementation does not receive ICMP errors. This violates the CoAP standard and can lead to unnecessary network traffic, bad user experience (when used for client requests) or even network attack amplification.

  • The server can not be used with the “any-address” (::, If it were allowed to bind there, it would not receive any indication from the operating system as to which of its own addresses a request was sent, and could not send the response with the appropriate sender address.

    (The udp6 transport does not suffer that shortcoming, simplesocketserver is typically only used when that is unavailable).

    With simplesocketserver, you need to explicitly give the IP address of your server in the bind argument of aiocoap.protocol.Context.create_server_context().

  • This transport is experimental and likely to change.

class aiocoap.transports.simplesocketserver.MessageInterfaceSimpleServer(mman: aiocoap.interfaces.MessageManager, log, loop)

Bases: aiocoap.transports.generic_udp.GenericMessageInterface

classmethod create_server(bind, ctx: aiocoap.interfaces.MessageManager, log, loop)