Index wasi args_get args_sizes_get clock_res_get clock_time_get environ_get environ_sizes_get fd_advise fd_allocate fd_close fd_datasync fd_fdstat_get fd_fdstat_set_flags fd_fdstat_set_rights fd_filestat_get fd_filestat_set_size fd_filestat_set_times fd_pread fd_prestat_dir_name fd_prestat_get fd_pwrite fd_read fd_readdir fd_renumber fd_seek fd_sync fd_tell fd_write file_stat_flags filestat iovec lookup_flags path_create_directory path_filestat_get path_filestat_set_times path_link path_open path_readlink path_remove_directory path_rename path_symlink path_unlink_file poll_oneoff proc_exit proc_raise random_get sched_yield sock_accept sock_recv sock_send sock_shutdown
Shut down socket send and receive channels.
sock_shutdown (
fd: i32The file descriptor of the socket to shut down.how: i32Specifies which channels on the socket to shut down.
) =>
error: i32 

The sock_shutdown() function is used to shut down the send and receive channels of a socket. It is similar to the shutdown function in POSIX. The function allows you to selectively shut down either the send channel, the receive channel, or both channels of the socket.

Notes

  • The sock_shutdown() function allows you to shut down the send and/or receive channels of a socket.
  • The how parameter specifies which channels to shut down. It can take one of the following values:
    • __WASI_SHUT_RD: Shut down the receive channel.
    • __WASI_SHUT_WR: Shut down the send channel.
    • __WASI_SHUT_RD | __WASI_SHUT_WR: Shut down both the send and receive channels.
  • The function maps the how value to the corresponding std::net::Shutdown enum variant and passes it to the underlying socket's shutdown() method.
  • The specific behavior of the sock_shutdown() function may vary depending on the runtime environment and underlying networking implementation.
Type Value Description
SHUT_RD 1 Shut down the receive channel
SHUT_WR 2 Shut down the send channel.
SHIT_RDWR 3 Shut down both the send and receive channels.