API Reference › Udp › Udp.send
method

Udp.send

Udp.send(socket, ip, port, bytes, len) -> int

Sends the first len bytes of bytes to ip:port as one datagram and returns the number of bytes sent, or -1.

Example

program Demo {
  entry {
    let s = Udp.open(port: 0)
    let buf = Memory.bytes(4)
    Memory.poke(buf, 0, 1)
    print(Udp.send(socket: s, ip: Udp.ip(text: "127.0.0.1"), port: Udp.port(socket: s), bytes: buf, len: 1))
  }
}
← All symbols