Lines Matching refs:socket

62     /// The operation is not valid in the socket's current state.
64 /// A new socket resource could not be created because of a system limit.
65 new-socket-limit,
78 /// The size of a datagram sent to a UDP socket exceeded the maximum
110 record ipv4-socket-address {
118 record ipv6-socket-address {
130 variant ip-socket-address {
131 ipv4(ipv4-socket-address),
132 ipv6(ipv6-socket-address),
198 /// See the wasi-socket proposal README.md for a comparison with getaddrinfo.
225 use network.{network, error-code, ip-socket-address, ip-address-family};
237 /// A TCP socket resource.
239 /// The socket can be in one of the following states:
256 /// `network::error-code` type, TCP socket methods may always return
259 resource tcp-socket {
260 /// Bind the socket to a specific network on the provided IP address and port.
264 /// If the TCP/UDP port is zero, the socket will be bound to a random free port.
266 /// Bind can be attempted multiple times on the same socket, even with
275 /// - `invalid-state`: The socket is already bound. (EINVAL)
284 …/// state of a recently closed socket on the same local address. In practice this means that the S…
285 …/// socket option should be set implicitly on all platforms, except on Windows where this is the d…
299 …start-bind: func(network: borrow<network>, local-address: ip-socket-address) -> result<_, error-co…
305 /// - the socket is transitioned into the `connected` state.
308 /// After a failed connection attempt, the socket will be in the `closed`
309 /// state and the only valid action left is to `drop` the socket. A single
310 /// socket can not be used to connect more than once.
318 …/// - `invalid-argument`: The socket is already attached to a different network. The `net…
319 /// - `invalid-state`: The socket is already in the `connected` state. (EISCONN)
320 …/// - `invalid-state`: The socket is already in the `listening` state. (EOPNOTSUPP, EI…
336 /// with a timeout of 0 on the socket descriptor. Followed by a check for
337 /// the `SO_ERROR` socket option, in case the poll signaled readiness.
345 …start-connect: func(network: borrow<network>, remote-address: ip-socket-address) -> result<_, erro…
350 /// Transitions the socket into the `listening` state.
352 /// Unlike POSIX, the socket must already be explicitly bound.
355 /// - `invalid-state`: The socket is not bound to any local address. (EDESTADDRREQ)
356 …/// - `invalid-state`: The socket is already in the `connected` state. (EISCONN, EINVA…
357 /// - `invalid-state`: The socket is already in the `listening` state.
377 /// Accept a new client socket.
379 …/// The returned socket is bound and in the `connected` state. The following properties are inheri…
389 /// On success, this function returns the newly accepted client socket along with
396 …/// - `new-socket-limit`: The new socket resource could not be created because of a system limit…
404 accept: func() -> result<tuple<tcp-socket, input-stream, output-stream>, error-code>;
408 /// > If the socket has not been bound to a local name, the value
411 …/// WASI is stricter and requires `local-address` to return `invalid-state` when the socket hasn't…
414 /// - `invalid-state`: The socket is not bound to any local address.
422 local-address: func() -> result<ip-socket-address, error-code>;
426 /// - `invalid-state`: The socket is not connected to a remote address. (ENOTCONN)
434 remote-address: func() -> result<ip-socket-address, error-code>;
435 /// Whether the socket is in the `listening` state.
437 /// Equivalent to the SO_ACCEPTCONN socket option.
440 /// Whether this is a IPv4 or IPv6 socket.
442 /// Equivalent to the SO_DOMAIN socket option.
453 …/// - `invalid-state`: (set) The socket is in the `connect-in-progress` or `connected` stat…
464 /// Equivalent to the SO_KEEPALIVE socket option.
475 /// Equivalent to the TCP_KEEPIDLE socket option. (TCP_KEEPALIVE on MacOS)
489 /// Equivalent to the TCP_KEEPINTVL socket option.
503 /// Equivalent to the TCP_KEEPCNT socket option.
511 /// Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options.
521 /// The kernel buffer space reserved for sends/receives on this socket.
527 /// Equivalent to the SO_RCVBUF and SO_SNDBUF socket options.
540 /// completion of any of the asynchronous operations of this socket.
548 /// `subscribe` only has to be called once per socket and can then be
549 /// (re)used for the remainder of the socket's lifetime.
560 /// - `receive`: The socket is not expecting to receive any data from
561 /// the peer. The `input-stream` associated with this socket will be
564 /// - `send`: The socket has no more data to send to the peer. The `output-stream`
565 /// associated with this socket will be closed and a FIN packet will be sent.
571 /// The shutdown function does not close (drop) the socket.
574 /// - `invalid-state`: The socket is not in the `connected` state. (ENOTCONN)
587 interface tcp-create-socket {
591 use tcp.{tcp-socket};
593 /// Create a new TCP socket.
595 /// Similar to `socket(AF_INET or AF_INET6, SOCK_STREAM, IPPROTO_TCP)` in POSIX.
599 …/// at time of creation, the socket is not bound to any `network` yet. Up to the moment `bind`/`co…
600 …/// is called, the socket is effectively an in-memory configuration object, unable to communicate …
606 …/// - `new-socket-limit`: The new socket resource could not be created because of a system limit.…
609 /// - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/socket.html>
610 /// - <https://man7.org/linux/man-pages/man2/socket.2.html>
612 /// - <https://man.freebsd.org/cgi/man.cgi?query=socket&sektion=2>
614 create-tcp-socket: func(address-family: ip-address-family) -> result<tcp-socket, error-code>;
622 use network.{network, error-code, ip-socket-address, ip-address-family};
636 remote-address: ip-socket-address,
651 remote-address: option<ip-socket-address>,
654 /// A UDP socket handle.
656 resource udp-socket {
657 /// Bind the socket to a specific network on the provided IP address and port.
661 /// If the port is zero, the socket will be bound to a random free port.
665 /// - `invalid-state`: The socket is already bound. (EINVAL)
684 …start-bind: func(network: borrow<network>, local-address: ip-socket-address) -> result<_, error-co…
689 …/// This function only changes the local socket configuration and does not generate any network tr…
690 …/// On success, the `remote-address` of the socket is updated. The `local-address` may be updated …
697 /// This method may be called multiple times on the same socket to change its association, but
711 /// Unlike in POSIX, the socket must already be explicitly bound.
717 /// - `invalid-state`: The socket is not bound.
728 …%stream: func(remote-address: option<ip-socket-address>) -> result<tuple<incoming-datagram-stream,…
732 /// > If the socket has not been bound to a local name, the value
735 …/// WASI is stricter and requires `local-address` to return `invalid-state` when the socket hasn't…
738 /// - `invalid-state`: The socket is not bound to any local address.
746 local-address: func() -> result<ip-socket-address, error-code>;
747 /// Get the address the socket is currently streaming to.
750 /// - `invalid-state`: The socket is not streaming to a specific remote address. (ENOTCONN)
758 remote-address: func() -> result<ip-socket-address, error-code>;
759 /// Whether this is a IPv4 or IPv6 socket.
761 /// Equivalent to the SO_DOMAIN socket option.
764 /// Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options.
774 /// The kernel buffer space reserved for sends/receives on this socket.
780 /// Equivalent to the SO_RCVBUF and SO_SNDBUF socket options.
792 /// Create a `pollable` which will resolve once the socket is ready for I/O.
802 /// Receive messages on the socket.
804 …/// This function attempts to receive up to `max-results` datagrams on the socket without blocking.
849 /// Send messages on the socket.
851 /// This function attempts to send all provided `datagrams` on the socket without blocking and
868 …/// - `invalid-argument`: The socket is in "connected" mode and `remote-address` is `some` …
869 …/// - `invalid-argument`: The socket is not "connected" and no value for `remote-address` w…
895 interface udp-create-socket {
899 use udp.{udp-socket};
901 /// Create a new UDP socket.
903 /// Similar to `socket(AF_INET or AF_INET6, SOCK_DGRAM, IPPROTO_UDP)` in POSIX.
907 …/// at time of creation, the socket is not bound to any `network` yet. Up to the moment `bind` is …
908 …/// the socket is effectively an in-memory configuration object, unable to communicate with the ou…
914 …/// - `new-socket-limit`: The new socket resource could not be created because of a system limit.…
917 /// - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/socket.html>
918 /// - <https://man7.org/linux/man-pages/man2/socket.2.html>
920 /// - <https://man.freebsd.org/cgi/man.cgi?query=socket&sektion=2>
922 create-udp-socket: func(address-family: ip-address-family) -> result<udp-socket, error-code>;
938 import udp-create-socket;
946 import tcp-create-socket;