Skip to content

ConnectedUDPSocket

[Source]

A connected UDP socket actor driven by a ConnectedUDPSocketNotify.

Wraps the net package's ConnectedUDPSocket class, ConnectedUDPSocketActor trait, and ConnectedUDPLifecycleEventReceiver trait into a single actor.

send is synchronous and returns a UDPSendResult — use it from within callbacks where the result matters. write is a fire-and-forget behavior for sending from other actors; the result is discarded.

actor tag ConnectedUDPSocket is
  ConnectedUDPSocketActor[ConnectedUDPRuntimeBackend ref] tag,
  ConnectedUDPLifecycleEventReceiver[ConnectedUDPRuntimeBackend ref] ref

Implements


Constructors

create

[Source]

Bind a UDP socket to host:port and connect it to peer_host:peer_port. Port "0" for the local side lets the OS assign an ephemeral port.

new tag create(
  auth: UDPAuth val,
  notify: ConnectedUDPSocketNotify iso,
  host: String val,
  port: String val,
  peer_host: String val,
  peer_port: String val,
  read_buffer_size: ReadBufferSize = net.DefaultReadBufferSize(),
  ip_version: IPVersion = net.DualStack,
  max_datagrams_per_turn: USize val = 256)
: ConnectedUDPSocket tag^

Parameters

Returns


Public Behaviours

write

[Source]

Send a datagram to the connected peer. Fire-and-forget: the send is silently dropped if the socket is not open. Use send from within a callback when the result matters.

be write(
  data: ByteSeq)

Parameters


dispose

[Source]

be dispose()

Public Functions

send

[Source]

Send one datagram to the connected peer. Returns UDPSendOk when the datagram was handed to the OS. UDP sends are synchronous and all-or-nothing.

Callable from any callback (where sock is ref). From outside the actor, use the write behavior instead.

fun ref send(
  data: ByteSeq)
: UDPSendResult

Parameters

Returns


close

[Source]

Close the socket. No graceful shutdown: the fd is closed immediately.

fun ref close()
: None val

Returns


local_address

[Source]

Return the local IP address the socket is bound to.

fun ref local_address()
: NetAddress val

Returns


remote_address

[Source]

Return the remote peer address the socket is connected to.

fun ref remote_address()
: NetAddress val

Returns


is_open

[Source]

True when the socket is connected and has not been closed.

fun box is_open()
: Bool val

Returns


is_closed

[Source]

True when the socket has been closed.

fun box is_closed()
: Bool val

Returns


get_so_rcvbuf

[Source]

Get the OS receive buffer size. Returns (errno, value).

fun box get_so_rcvbuf()
: (U32 val , U32 val)

Returns


set_so_rcvbuf

[Source]

Set the OS receive buffer size. Returns 0 on success, or errno.

fun box set_so_rcvbuf(
  bufsize: U32 val)
: U32 val

Parameters

  • bufsize: U32 val

Returns


get_so_sndbuf

[Source]

Get the OS send buffer size. Returns (errno, value).

fun box get_so_sndbuf()
: (U32 val , U32 val)

Returns


set_so_sndbuf

[Source]

Set the OS send buffer size. Returns 0 on success, or errno.

fun box set_so_sndbuf(
  bufsize: U32 val)
: U32 val

Parameters

  • bufsize: U32 val

Returns


getsockopt_u32

[Source]

Get a socket option as a U32. Returns (errno, value).

fun box getsockopt_u32(
  level: I32 val,
  option_name: I32 val)
: (U32 val , U32 val)

Parameters

  • level: I32 val
  • option_name: I32 val

Returns


setsockopt_u32

[Source]

Set a socket option as a U32. Returns 0 on success, or errno.

fun box setsockopt_u32(
  level: I32 val,
  option_name: I32 val,
  option: U32 val)
: U32 val

Parameters

  • level: I32 val
  • option_name: I32 val
  • option: U32 val

Returns