blob: db67e23af672e36be870a7f8a98923130dd57c23 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
## Name
recvfd - receive a file descriptor from a local socket peer
## Synopsis
```**c++
#include <sys/socket.h>
int recvfd(int sockfd);
```
## Description
Receive an open file descriptor from a local socket peer connected via `sockfd`. This is a non-blocking call that will fail if there is no file descriptor waiting in the socket's queue.
File descriptors are sent out-of-band and do not affect the regular data streams.
## Return value
If a file descriptor is successfully received, it is returned as a non-negative integer. Otherwise, -1 is returned and `errno` is set to indicate the error.
## Errors
* `EBADF`: `sockfd` is not an open file descriptor.
* `ENOTSOCK`: `sockfd` does not refer to a socket.
* `EAFNOSUPPORT`: `sockfd` does not refer to a local domain socket.
* `EINVAL`: `sockfd` does not refer to a connected or accepted socket.
* `EAGAIN`: There is no file descriptor queued on this socket.
## History
`recvfd()` was first introduced in Plan 9 from User Space.
## See also
* [`sendfd`(2)](sendfd.md)
|