Struct wasmcloud_component::wasi::sockets::udp::OutgoingDatagramStream
source · pub struct OutgoingDatagramStream { /* private fields */ }Implementations§
source§impl OutgoingDatagramStream
impl OutgoingDatagramStream
sourcepub fn check_send(&self) -> Result<u64, ErrorCode>
pub fn check_send(&self) -> Result<u64, ErrorCode>
Check readiness for sending. This function never blocks.
Returns the number of datagrams permitted for the next call to send,
or an error. Calling send with more datagrams than this function has
permitted will trap.
When this function returns ok(0), the subscribe pollable will
become ready when this function will report at least ok(1), or an
error.
Never returns would-block.
source§impl OutgoingDatagramStream
impl OutgoingDatagramStream
sourcepub fn send(&self, datagrams: &[OutgoingDatagram]) -> Result<u64, ErrorCode>
pub fn send(&self, datagrams: &[OutgoingDatagram]) -> Result<u64, ErrorCode>
Send messages on the socket.
This function attempts to send all provided datagrams on the socket without blocking and
returns how many messages were actually sent (or queued for sending). This function never
returns error(would-block). If none of the datagrams were able to be sent, ok(0) is returned.
This function semantically behaves the same as iterating the datagrams list and sequentially
sending each individual datagram until either the end of the list has been reached or the first error occurred.
If at least one datagram has been sent successfully, this function never returns an error.
If the input list is empty, the function returns ok(0).
Each call to send must be permitted by a preceding check-send. Implementations must trap if
either check-send was not called or datagrams contains more items than check-send permitted.
§Typical errors
invalid-argument: Theremote-addresshas the wrong address family. (EAFNOSUPPORT)invalid-argument: The IP address inremote-addressis set to INADDR_ANY (0.0.0.0/::). (EDESTADDRREQ, EADDRNOTAVAIL)invalid-argument: The port inremote-addressis set to 0. (EDESTADDRREQ, EADDRNOTAVAIL)invalid-argument: The socket is in “connected” mode andremote-addressissomevalue that does not match the address passed tostream. (EISCONN)invalid-argument: The socket is not “connected” and no value forremote-addresswas provided. (EDESTADDRREQ)remote-unreachable: The remote address is not reachable. (ECONNRESET, ENETRESET on Windows, EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET)connection-refused: The connection was refused. (ECONNREFUSED)datagram-too-large: The datagram is too large. (EMSGSIZE)
§References
- https://pubs.opengroup.org/onlinepubs/9699919799/functions/sendto.html
- https://pubs.opengroup.org/onlinepubs/9699919799/functions/sendmsg.html
- https://man7.org/linux/man-pages/man2/send.2.html
- https://man7.org/linux/man-pages/man2/sendmmsg.2.html
- https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-send
- https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-sendto
- https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasendmsg
- https://man.freebsd.org/cgi/man.cgi?query=send&sektion=2