Debian Codegraph @

vendor/wit-component/tests/interfaces/wasi-http/deps/sockets/tcp-create-socket.wit

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