Skip to main content





The UDPSocket class represents a single UDP (User Datagram Protocol) network socket available on the local network only.

Instances of the class are not created manually, but solely by calling the imp API method interface.openudp(). This method attempts to create a UDP socket for sending and receiving data via the local network. If this operation is successful, interface.openudp() returns an instance, udpsocket.

Note UDP communication is only available through WiFi and/or Ethernet interfaces, not cellular.

This instance can be used to send data and, via a registered callback, receive incoming datagrams. Once the socket is open (ie. once it has been bound to a port, which is applied during configuration or when data is first sent) it will remain so until closed manually (with udpsocket.close()) or automatically (ie. when all variable holding a reference to it go out of scope).

Maximum Data Length

All imps have the same standard Ethernet MTU (1460 bytes), and all support IP fragmentation. Outbound datagrams larger than the MTU will be fragmented. Users should note that a fragmented datagram will be lost if any of its fragments are lost, so for maximum reliability datagrams should be smaller than the MTU.

Rate Limits

Outgoing UDP packets are rate limited, to protect the local network and impOS connectivity. You can send up to 100 packets simultaneously in burst mode, or 25 packets a second continuously. In other words, an initial allowance of 100 packets is replenished back up to 100 at a rate of 25 per second.

Member Entities

The udpsocket object has the following member methods: