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

Function socket

src/backend/linux_raw/net/syscalls.rs:41–62  ·  view source on GitHub ↗
(
    family: AddressFamily,
    type_: SocketType,
    protocol: Option<Protocol>,
)

Source from the content-addressed store, hash-verified

39
40#[inline]
41pub(crate) fn socket(
42 family: AddressFamily,
43 type_: SocketType,
44 protocol: Option<Protocol>,
45) -> io::Result<OwnedFd> {
46 #[cfg(not(target_arch = "x86"))]
47 unsafe {
48 ret_owned_fd(syscall_readonly!(__NR_socket, family, type_, protocol))
49 }
50 #[cfg(target_arch = "x86")]
51 unsafe {
52 ret_owned_fd(syscall_readonly!(
53 __NR_socketcall,
54 x86_sys(SYS_SOCKET),
55 slice_just_addr::<ArgReg<'_, SocketArg>, _>(&[
56 family.into(),
57 type_.into(),
58 protocol.into(),
59 ])
60 ))
61 }
62}
63
64#[inline]
65pub(crate) fn socket_with(

Callers

nothing calls this directly

Calls 1

ret_owned_fdFunction · 0.50

Tested by

no test coverage detected