MCPcopy Create free account
hub / github.com/bytecodealliance/rustix / socketpair

Function socketpair

src/backend/libc/net/syscalls.rs:412–434  ·  view source on GitHub ↗
(
    domain: AddressFamily,
    type_: SocketType,
    flags: SocketFlags,
    protocol: Option<Protocol>,
)

Source from the content-addressed store, hash-verified

410
411#[cfg(not(windows))]
412pub(crate) fn socketpair(
413 domain: AddressFamily,
414 type_: SocketType,
415 flags: SocketFlags,
416 protocol: Option<Protocol>,
417) -> io::Result<(OwnedFd, OwnedFd)> {
418 let raw_protocol = match protocol {
419 Some(p) => p.0.get(),
420 None => 0,
421 };
422 unsafe {
423 let mut fds = MaybeUninit::<[OwnedFd; 2]>::uninit();
424 ret(c::socketpair(
425 c::c_int::from(domain.0),
426 (type_.0 | flags.bits()) as c::c_int,
427 raw_protocol as c::c_int,
428 fds.as_mut_ptr().cast::<c::c_int>(),
429 ))?;
430
431 let [fd0, fd1] = fds.assume_init();
432 Ok((fd0, fd1))
433 }
434}

Callers

nothing calls this directly

Calls 4

assume_initMethod · 0.80
retFunction · 0.50
getMethod · 0.45
as_mut_ptrMethod · 0.45

Tested by

no test coverage detected