ConnectedUDPSocket¶
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¶
- ConnectedUDPSocketActor[ConnectedUDPRuntimeBackend ref] tag
- ConnectedUDPLifecycleEventReceiver[ConnectedUDPRuntimeBackend ref] ref
Constructors¶
create¶
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¶
- 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
Returns¶
- ConnectedUDPSocket tag^
Public Behaviours¶
write¶
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.
Parameters¶
- data: ByteSeq
dispose¶
Public Functions¶
send¶
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.
Parameters¶
- data: ByteSeq
Returns¶
close¶
Close the socket. No graceful shutdown: the fd is closed immediately.
Returns¶
- None val
local_address¶
Return the local IP address the socket is bound to.
Returns¶
- NetAddress val
remote_address¶
Return the remote peer address the socket is connected to.
Returns¶
- NetAddress val
is_open¶
True when the socket is connected and has not been closed.
Returns¶
- Bool val
is_closed¶
True when the socket has been closed.
Returns¶
- Bool val
get_so_rcvbuf¶
Get the OS receive buffer size. Returns (errno, value).
Returns¶
set_so_rcvbuf¶
Set the OS receive buffer size. Returns 0 on success, or errno.
Parameters¶
- bufsize: U32 val
Returns¶
- U32 val
get_so_sndbuf¶
Get the OS send buffer size. Returns (errno, value).
Returns¶
set_so_sndbuf¶
Set the OS send buffer size. Returns 0 on success, or errno.
Parameters¶
- bufsize: U32 val
Returns¶
- U32 val
getsockopt_u32¶
Get a socket option as a U32. Returns (errno, value).
Parameters¶
Returns¶
setsockopt_u32¶
Set a socket option as a U32. Returns 0 on success, or errno.
Parameters¶
Returns¶
- U32 val