1-
1+ @since ( version = 0.2.0 )
22interface tcp {
3+ @since (version = 0.2.0 )
34 use wasi :io /streams @ 0.2.0 . {input-stream , output-stream };
5+ @since (version = 0.2.0 )
46 use wasi :io /poll @ 0.2.0 . {pollable };
7+ @since (version = 0.2.0 )
58 use wasi :clocks /monotonic-clock @ 0.2.0 . {duration };
9+ @since (version = 0.2.0 )
610 use network . {network , error-code , ip-socket-address , ip-address-family };
711
12+ @since (version = 0.2.0 )
813 enum shutdown-type {
914 /// Similar to `SHUT_RD` in POSIX.
1015 receive ,
@@ -37,6 +42,7 @@ interface tcp {
3742 /// In addition to the general error codes documented on the
3843 /// `network::error-code` type, TCP socket methods may always return
3944 /// `error(invalid-state)` when in the `closed` state.
45+ @since (version = 0.2.0 )
4046 resource tcp-socket {
4147 /// Bind the socket to a specific network on the provided IP address and port.
4248 ///
@@ -76,7 +82,9 @@ interface tcp {
7682 /// - <https://man7.org/linux/man-pages/man2/bind.2.html>
7783 /// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-bind>
7884 /// - <https://man.freebsd.org/cgi/man.cgi?query=bind&sektion=2&format=html>
85+ @since (version = 0.2.0 )
7986 start-bind : func (network : borrow <network >, local-address : ip-socket-address ) -> result <_ , error-code >;
87+ @since (version = 0.2.0 )
8088 finish-bind : func () -> result <_ , error-code >;
8189
8290 /// Connect to a remote endpoint.
@@ -121,7 +129,9 @@ interface tcp {
121129 /// - <https://man7.org/linux/man-pages/man2/connect.2.html>
122130 /// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-connect>
123131 /// - <https://man.freebsd.org/cgi/man.cgi?connect>
132+ @since (version = 0.2.0 )
124133 start-connect : func (network : borrow <network >, remote-address : ip-socket-address ) -> result <_ , error-code >;
134+ @since (version = 0.2.0 )
125135 finish-connect : func () -> result <tuple <input-stream , output-stream >, error-code >;
126136
127137 /// Start listening for new connections.
@@ -149,7 +159,9 @@ interface tcp {
149159 /// - <https://man7.org/linux/man-pages/man2/listen.2.html>
150160 /// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-listen>
151161 /// - <https://man.freebsd.org/cgi/man.cgi?query=listen&sektion=2>
162+ @since (version = 0.2.0 )
152163 start-listen : func () -> result <_ , error-code >;
164+ @since (version = 0.2.0 )
153165 finish-listen : func () -> result <_ , error-code >;
154166
155167 /// Accept a new client socket.
@@ -178,6 +190,7 @@ interface tcp {
178190 /// - <https://man7.org/linux/man-pages/man2/accept.2.html>
179191 /// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-accept>
180192 /// - <https://man.freebsd.org/cgi/man.cgi?query=accept&sektion=2>
193+ @since (version = 0.2.0 )
181194 accept : func () -> result <tuple <tcp-socket , input-stream , output-stream >, error-code >;
182195
183196 /// Get the bound local address.
@@ -196,6 +209,7 @@ interface tcp {
196209 /// - <https://man7.org/linux/man-pages/man2/getsockname.2.html>
197210 /// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-getsockname>
198211 /// - <https://man.freebsd.org/cgi/man.cgi?getsockname>
212+ @since (version = 0.2.0 )
199213 local-address : func () -> result <ip-socket-address , error-code >;
200214
201215 /// Get the remote address.
@@ -208,16 +222,19 @@ interface tcp {
208222 /// - <https://man7.org/linux/man-pages/man2/getpeername.2.html>
209223 /// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-getpeername>
210224 /// - <https://man.freebsd.org/cgi/man.cgi?query=getpeername&sektion=2&n=1>
225+ @since (version = 0.2.0 )
211226 remote-address : func () -> result <ip-socket-address , error-code >;
212227
213228 /// Whether the socket is in the `listening` state.
214229 ///
215230 /// Equivalent to the SO_ACCEPTCONN socket option.
231+ @since (version = 0.2.0 )
216232 is-listening : func () -> bool ;
217233
218234 /// Whether this is a IPv4 or IPv6 socket.
219235 ///
220236 /// Equivalent to the SO_DOMAIN socket option.
237+ @since (version = 0.2.0 )
221238 address-family : func () -> ip-address-family ;
222239
223240 /// Hints the desired listen queue size. Implementations are free to ignore this.
@@ -229,6 +246,7 @@ interface tcp {
229246 /// - `not-supported` : (set) The platform does not support changing the backlog size after the initial listen.
230247 /// - `invalid-argument` : (set) The provided value was 0.
231248 /// - `invalid-state` : (set) The socket is in the `connect-in-progress` or `connected` state.
249+ @since (version = 0.2.0 )
232250 set-listen-backlog-size : func (value : u64 ) -> result <_ , error-code >;
233251
234252 /// Enables or disables keepalive.
@@ -240,7 +258,9 @@ interface tcp {
240258 /// These properties can be configured while `keep-alive-enabled` is false, but only come into effect when `keep-alive-enabled` is true.
241259 ///
242260 /// Equivalent to the SO_KEEPALIVE socket option.
261+ @since (version = 0.2.0 )
243262 keep-alive-enabled : func () -> result <bool , error-code >;
263+ @since (version = 0.2.0 )
244264 set-keep-alive-enabled : func (value : bool ) -> result <_ , error-code >;
245265
246266 /// Amount of time the connection has to be idle before TCP starts sending keepalive packets.
@@ -253,7 +273,9 @@ interface tcp {
253273 ///
254274 /// # Typical errors
255275 /// - `invalid-argument` : (set) The provided value was 0.
276+ @since (version = 0.2.0 )
256277 keep-alive-idle-time : func () -> result <duration , error-code >;
278+ @since (version = 0.2.0 )
257279 set-keep-alive-idle-time : func (value : duration ) -> result <_ , error-code >;
258280
259281 /// The time between keepalive packets.
@@ -266,7 +288,9 @@ interface tcp {
266288 ///
267289 /// # Typical errors
268290 /// - `invalid-argument` : (set) The provided value was 0.
291+ @since (version = 0.2.0 )
269292 keep-alive-interval : func () -> result <duration , error-code >;
293+ @since (version = 0.2.0 )
270294 set-keep-alive-interval : func (value : duration ) -> result <_ , error-code >;
271295
272296 /// The maximum amount of keepalive packets TCP should send before aborting the connection.
@@ -279,7 +303,9 @@ interface tcp {
279303 ///
280304 /// # Typical errors
281305 /// - `invalid-argument` : (set) The provided value was 0.
306+ @since (version = 0.2.0 )
282307 keep-alive-count : func () -> result <u32 , error-code >;
308+ @since (version = 0.2.0 )
283309 set-keep-alive-count : func (value : u32 ) -> result <_ , error-code >;
284310
285311 /// Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options.
@@ -288,7 +314,9 @@ interface tcp {
288314 ///
289315 /// # Typical errors
290316 /// - `invalid-argument` : (set) The TTL value must be 1 or higher.
317+ @since (version = 0.2.0 )
291318 hop-limit : func () -> result <u8 , error-code >;
319+ @since (version = 0.2.0 )
292320 set-hop-limit : func (value : u8 ) -> result <_ , error-code >;
293321
294322 /// The kernel buffer space reserved for sends/receives on this socket.
@@ -301,9 +329,13 @@ interface tcp {
301329 ///
302330 /// # Typical errors
303331 /// - `invalid-argument` : (set) The provided value was 0.
332+ @since (version = 0.2.0 )
304333 receive-buffer-size : func () -> result <u64 , error-code >;
334+ @since (version = 0.2.0 )
305335 set-receive-buffer-size : func (value : u64 ) -> result <_ , error-code >;
336+ @since (version = 0.2.0 )
306337 send-buffer-size : func () -> result <u64 , error-code >;
338+ @since (version = 0.2.0 )
307339 set-send-buffer-size : func (value : u64 ) -> result <_ , error-code >;
308340
309341 /// Create a `pollable` which can be used to poll for, or block on,
@@ -323,6 +355,7 @@ interface tcp {
323355 ///
324356 /// Note: this function is here for WASI Preview2 only.
325357 /// It's planned to be removed when `future` is natively supported in Preview3.
358+ @since (version = 0.2.0 )
326359 subscribe : func () -> pollable ;
327360
328361 /// Initiate a graceful shutdown.
@@ -348,6 +381,7 @@ interface tcp {
348381 /// - <https://man7.org/linux/man-pages/man2/shutdown.2.html>
349382 /// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-shutdown>
350383 /// - <https://man.freebsd.org/cgi/man.cgi?query=shutdown&sektion=2>
384+ @since (version = 0.2.0 )
351385 shutdown : func (shutdown-type : shutdown-type ) -> result <_ , error-code >;
352386 }
353387}
0 commit comments