---
id: udp
title: Udp
order: 9
---
Plain IPv4 datagrams, polled — the transport under a game's own netcode: peer-to-peer play, a LAN lobby, a STUN query. Open a socket with Udp.open, send with Udp.send, and each frame drain what arrived with Udp.recv, which returns 0 when nothing is waiting and never blocks. The sender of the last datagram read is Udp.from_ip / from_port.
An address is an int: a.b.c.d is (a << 24) | (b << 16) | (c << 8) | d, converted by Udp.ip and Udp.ip_text. Datagrams can be lost, repeated and reordered; the protocol a game builds on top says what to do about that. Like Http.* it is out-of-band and must never feed the deterministic lockstep/replay simulation directly. BSD sockets on macOS, Winsock on Windows.