plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

sendfd.3 (1014B)


      1 .TH SENDFD 3
      2 .SH NAME
      3 sendfd, recvfd \- pass file descriptors along Unix domain sockets
      4 .SH SYNOPSIS
      5 .B
      6 #include <u.h>
      7 .PP
      8 .B
      9 #include <libc.h>
     10 .PP
     11 .B
     12 int	sendfd(int socket, int fd)
     13 .PP
     14 .B
     15 int	recvfd(int socket)
     16 .SH DESCRIPTION
     17 .I Recvfd
     18 and
     19 .I sendfd
     20 can be used to pass an open file descriptor over
     21 a Unix domain socket from one process to another.
     22 Since
     23 .MR pipe (3)
     24 is implemented with
     25 .MR socketpair (2)
     26 instead of
     27 .MR pipe (2) ,
     28 .I socket
     29 can be a file descriptor obtained from
     30 .MR pipe (3) .
     31 .PP
     32 .I Sendfd
     33 sends the file descriptor
     34 .I fd
     35 along the socket to a process calling
     36 .I recvfd 
     37 on the other end.
     38 .PP
     39 It is assumed that the two sides have coordinated
     40 and agreed to transfer a file descriptor already, so
     41 that the
     42 .I sendfd
     43 is met with a
     44 .I recvfd
     45 instead of an ordinary
     46 .IR read .
     47 .PP
     48 The file descriptor number may change on its way
     49 between processes, but the kernel structure it represents
     50 will not.
     51 .SH SOURCE
     52 .B \*9/src/lib9/sendfd.c
     53 .SH SEE ALSO
     54 .MR socketpair (2) ,
     55 .I sendmsg
     56 in
     57 .MR send (2)