Skip to content
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

NameTypeDirDescription
sint-
bufvoid-
lensize_t-
flagsint-
fromstruct sockaddr-
fromlenaddrint-

Version history

XNU tagmacOS#
xnu-1456.1.26macOS 10.6 Snow Leopard29
xnu-1486.2.1129
xnu-1504.15.329
xnu-1504.3.1229
xnu-1504.7.429
xnu-1504.9.1729
xnu-1504.9.2629
xnu-1504.9.3729

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