Skip to content

UDPBackend

[Source]

The UDP operations a socket needs from the runtime. UDPRuntimeBackend is the production implementation; test code can substitute a fake to drive the socket state machine without real sockets.

trait ref UDPBackend

Constructors

create

[Source]

new ref create()
: UDPBackend ref^

Returns


Public Functions

bind

[Source]

Bind a UDP socket to host:port and subscribe the_actor for readiness events. Returns the ASIO event, or a null event on failure.

fun ref bind(
  the_actor: AsioEventNotify tag,
  host: String val,
  port: String val,
  ip_version: IPVersion = DualStack)
: AsioEventID

Parameters

Returns


close

[Source]

Close the socket.

fun ref close(
  fd: U32 val)
: None val

Parameters

Returns


recvfrom

[Source]

Receive one datagram into buffer. Returns the tri-state socket result, the number of bytes received, and the sender address.

fun ref recvfrom(
  event: AsioEventID,
  buffer: Pointer[U8 val] tag,
  size: USize val)
: (SocketResult , USize val , NetAddress iso^)

Parameters

Returns


sendto

[Source]

Send one datagram. Returns SocketResultOk on success, SocketResultRetry when the OS buffer is full, or SocketResultError on failure. No byte count: POSIX datagram sendto is all-or-nothing.

fun ref sendto(
  fd: U32 val,
  data: ByteSeq,
  to: NetAddress box)
: SocketResult

Parameters

Returns


sockname

[Source]

Fill ip with the local address of fd. Returns true on success.

fun ref sockname(
  fd: U32 val,
  ip: NetAddress tag)
: Bool val

Parameters

Returns