Resource
incoming-datagram-stream
No description available.
resource incoming-datagram-stream;F receive
receive: func(max-results: u64) -> result<list<incoming-datagram>, error-code>;Receive messages on the socket.
This function attempts to receive up to max-results datagrams on the socket without blocking.
The returned list may contain fewer elements than requested, but never more.
This function returns successfully with an empty list when either:
max-resultsis 0, or:max-resultsis greater than 0, but no results are immediately available. This function never returnserror(would-block).
Typical errors
remote-unreachable: The remote address is not reachable. (ECONNRESET, ENETRESET on Windows, EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET)connection-refused: The connection was refused. (ECONNREFUSED)
References
- https://pubs.opengroup.org/onlinepubs/9699919799/functions/recvfrom.html
- https://pubs.opengroup.org/onlinepubs/9699919799/functions/recvmsg.html
- https://man7.org/linux/man-pages/man2/recv.2.html
- https://man7.org/linux/man-pages/man2/recvmmsg.2.html
- https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-recv
- https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-recvfrom
- https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ms741687(v=vs.85)
- https://man.freebsd.org/cgi/man.cgi?query=recv&sektion=2
F subscribe
subscribe: func() -> pollable;Create a pollable which will resolve once the stream is ready to receive again.
Note: this function is here for WASI 0.2 only.
It's planned to be removed when future is natively supported in Preview3.