Function wasmer_wasix::syscalls::wasix::sock_pair::sock_pair

source ·
pub fn sock_pair<M: MemorySize>(
    ctx: FunctionEnvMut<'_, WasiEnv>,
    af: Addressfamily,
    ty: Socktype,
    pt: SockProto,
    ro_sock1: WasmPtr<Fd, M>,
    ro_sock2: WasmPtr<Fd, M>,
) -> Result<Errno, WasiError>
Expand description

§sock_pair()

Create an interconnected socket pair; or at least it’s supposed to.

Currently, this creates a pipe rather than a pair of sockets. Before this syscall was added, wasix-libc would just do pipe2 in its socketpair implementation. Since we fixed pipe2 to return a simplex pipe, that was no longer an option; hence this syscall was added, but the implementation still uses a pipe as the underlying communication mechanism. This is not the correct implementation and needs to be fixed. We hope that the pipe is sufficient for anything that doesn’t do socket-specific stuff, such as sending out-of-band packets.

Note: This is (supposed to be) similar to socketpair in POSIX using PF_INET

§Parameters

  • af - Address family
  • socktype - Socket type, either datagram or stream
  • sock_proto - Socket protocol

§Return

The file descriptor of the socket that has been opened.