BSD syscall#29
svc · unix #29
recvfrom
Receives a datagram or stream segment and optionally records the sender's address.
Prototype
int recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, int *fromlenaddr);Returns: int
Arguments
| Name | Type | Dir | Description |
|---|---|---|---|
| s | int | - | |
| buf | void | - | |
| len | size_t | - | |
| flags | int | - | |
| from | struct sockaddr | - | |
| fromlenaddr | int | - |
Version history
| XNU tag | macOS | # |
|---|---|---|
| xnu-1456.1.26 | macOS 10.6 Snow Leopard | 29 |
| xnu-1486.2.11 | — | 29 |
| xnu-1504.15.3 | — | 29 |
| xnu-1504.3.12 | — | 29 |
| xnu-1504.7.4 | — | 29 |
| xnu-1504.9.17 | — | 29 |
| xnu-1504.9.26 | — | 29 |
| xnu-1504.9.37 | — | 29 |
Notes
When the source address pointer is NULL, recvfrom degenerates to recv. For SOCK_DGRAM the kernel pulls one mbuf cluster off so_rcv; for SOCK_STREAM it drains up to len bytes or the next PSH boundary. MSG_PEEK leaves data in the buffer, MSG_WAITALL extends the wait until either len bytes or EOF, and MSG_DONTWAIT overrides O_NONBLOCK for this call only.
Detection
Per-byte visibility requires a NEFilterDataProvider that returns .needRules on the flow, then inspects each NEFilterDataVerdict.dataWithVerdict chunk. ES has no recv event.
Related APIs
recvmsgrecvmsg_xreadsendtoselect