Skip to main content

socketpair

Function socketpair 

Source
pub fn socketpair(
    domain: SocketDomain,
    ty: SocketType,
    protocol: i32,
) -> Result<(OwnedFd, OwnedFd), Errno>
Expand description

Crée une paire de sockets connectés.

Wrappeur de socketpair(2). Équivalent à créer un pipe mais pour les sockets Unix. Les deux FDs retournés sont symétriques.

Seuls les sockets Unix (AF_UNIX) supportent socketpair sur Linux. SOCK_CLOEXEC est ajouté automatiquement.

§Parameters

  • domain : doit être [SocketDomain::Unix] sur Linux.
  • ty : type de socket.
  • protocol : 0 = défaut.

§Errors

  • EAFNOSUPPORT : domaine non supporté (non-Unix).
  • EMFILE/ENFILE : quotas FD atteints.

§Examples

use air_sys_syscall::net::socketpair;
use air_sys_types::net::{SocketDomain, SocketType};

let (fd_a, fd_b) = socketpair(SocketDomain::Unix, SocketType::Stream, 0)
    .expect("socketpair");