Accept a new incoming connection
sock_accept (
sock: i32The file descriptor of the listening socket on which to accept a connectionfd_flags: i32The desired values of the file descriptor flags for the new socketro_fd: i32A WebAssembly pointer where the file descriptor of the new socket will be writtenro_addr: i32A WebAssembly pointer where the address of the remote client will be written
) => The sock_accept()
function is used to accept a new incoming connection on a listening socket. It is similar to the accept
function in POSIX.
When a connection is accepted, a new socket is created and returned. This new socket represents the communication channel with the client.
Notes
- The
sock_accept()
function accepts a new incoming connection on a listening socket. - The function blocks until a connection request is received.
- Upon successful acceptance of a connection, a new socket is created to handle communication with the client.
- The file descriptor flags specified by
fd_flags
control the behavior of the new socket. - The address of the remote client, including the IP address and port number, is written to the memory location pointed to by
ro_addr
. - The specific behavior of the
sock_accept()
function may vary depending on the runtime environment and underlying networking implementation.