Module sys/udp

sys/udp

Async UDP socket operations.

Provides UDP socket wrappers around the low-level C runtime externs. Reuses SockAddr and address helpers from tcp.yo.

All async operations return IOFuture which resolves to:

  • Positive value: success (fd for socket, bytes for sendto/recvfrom, 0 for others)
  • Negative value: -errno on failure

Functions

socket function
fn(domain : i32, protocol : i32) -> IOFuture

Parameters

NameTypeNotes
domaini32
protocoli32

Returns: IOFuture

bind function
fn(sockfd : i32, addr : *(u8), addrlen : u32) -> IOFuture

Parameters

NameTypeNotes
sockfdi32
addr*(u8)
addrlenu32

Returns: IOFuture

sendto function
fn(sockfd : i32, buf : *(u8), len : usize, flags : i32, dest_addr : *(u8), addrlen : u32) -> IOFuture

Parameters

NameTypeNotes
sockfdi32
buf*(u8)
lenusize
flagsi32
dest_addr*(u8)
addrlenu32

Returns: IOFuture

recvfrom function
fn(sockfd : i32, buf : *(u8), len : usize, flags : i32, src_addr : *(u8), addrlen : *(u32)) -> IOFuture

Parameters

NameTypeNotes
sockfdi32
buf*(u8)
lenusize
flagsi32
src_addr*(u8)
addrlen*(u32)

Returns: IOFuture

send function
fn(sockfd : i32, buf : *(u8), len : usize, flags : i32) -> IOFuture

Parameters

NameTypeNotes
sockfdi32
buf*(u8)
lenusize
flagsi32

Returns: IOFuture

recv function
fn(sockfd : i32, buf : *(u8), len : usize, flags : i32) -> IOFuture

Parameters

NameTypeNotes
sockfdi32
buf*(u8)
lenusize
flagsi32

Returns: IOFuture

close function
fn(fd : i32) -> IOFuture

Parameters

NameTypeNotes
fdi32

Returns: IOFuture

setsockopt function
fn(sockfd : i32, level : i32, optname : i32, optval : *(u8), optlen : u32) -> IOFuture

Parameters

NameTypeNotes
sockfdi32
leveli32
optnamei32
optval*(u8)
optlenu32

Returns: IOFuture

getsockopt function
fn(sockfd : i32, level : i32, optname : i32, optval : *(u8), optlen : *(u32)) -> IOFuture

Parameters

NameTypeNotes
sockfdi32
leveli32
optnamei32
optval*(u8)
optlen*(u32)

Returns: IOFuture