Debian Codegraph @

.cargo/vendor/wasip2/wit/deps/sockets/tcp-create-socket.wit

raw
1 @since(version = 0.2.0)
2 interface tcp-create-socket {
3 @since(version = 0.2.0)
4 use network.{network, error-code, ip-address-family};
5 @since(version = 0.2.0)
6 use tcp.{tcp-socket};
7
8 /// Create a new TCP socket.
9 ///
10 /// Similar to `socket(AF_INET or AF_INET6, SOCK_STREAM, IPPROTO_TCP)` in POSIX.
11 /// On IPv6 sockets, IPV6_V6ONLY is enabled by default and can't be configured otherwise.
12 ///
13 /// This function does not require a network capability handle. This is considered to be safe because
14 /// at time of creation, the socket is not bound to any `network` yet. Up to the moment `bind`/`connect`
15 /// is called, the socket is effectively an in-memory configuration object, unable to communicate with the outside world.
16 ///
17 /// All sockets are non-blocking. Use the wasi-poll interface to block on asynchronous operations.
18 ///
19 /// # Typical errors
20 /// - `not-supported`: The specified `address-family` is not supported. (EAFNOSUPPORT)
21 /// - `new-socket-limit`: The new socket resource could not be created because of a system limit. (EMFILE, ENFILE)
22 ///
23 /// # References
24 /// - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/socket.html>
25 /// - <https://man7.org/linux/man-pages/man2/socket.2.html>
26 /// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasocketw>
27 /// - <https://man.freebsd.org/cgi/man.cgi?query=socket&sektion=2>
28 @since(version = 0.2.0)
29 create-tcp-socket: func(address-family: ip-address-family) -> result<tcp-socket, error-code>;
30 }