pmf
pmf

Reputation: 7749

Socket reading and timestamps

When reading from a (non-stream) socket in Linux, I can get the (hardware-generated) timestamp of the last received message via a ioctl(sock, SIOCGSTAMP, &tv). However, this poses two problems:

My question is how to achieve receiving messages and their timestamps in as few syscalls as possible. It would be perfect if there was a syscall with semantics like "read as much messages as are pending and their timestamps".

Upvotes: 6

Views: 8622

Answers (1)

Nikolai Fetissov
Nikolai Fetissov

Reputation: 84151

Use recvmmsg(2) system call, if available with your kernel, and set SO_TIMESTAMP option.

Upvotes: 6

Related Questions