Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Practical uses of readv?

12 views
Skip to first unread message

Rainer Weikusat

unread,
Jun 1, 2012, 2:05:07 PM6/1/12
to
For this first time in sixteen years, I came into a situation where
readv (recvmsg) was actually useful: In order to dump the
'non-ESP marker' in front of an ISAKMP message when NAT-T is being
used for a particular 'IPsec session'. So far, I've assumed that
'scatter read' mainly exists for symmetry reasons. Anyone ever used
that for anything? And if so, for what?

Johann Klammer

unread,
Jun 1, 2012, 3:12:55 PM6/1/12
to
Reading TS packets from a DVB device, before software demultiplexing.
Each packet 188 bytes and has to(possibly) go to a different place.

Ersek, Laszlo

unread,
Jun 1, 2012, 4:20:28 PM6/1/12
to
I used recvmsg() in an UDP-based file transfer program. The data packet
format was something like 2 octets "sender slot number" (in network byte
order), 8 octets packet serial number (ditto), and payload. The ACK format
was the same, minus payload.

In the receiver, the first two fields were scattered into an u16 and an
u32[2]. The payload was scattered into a malloc()'d buffer and possibly
linked into a sliding window, based on the packet serial number. The first
two fields were reused for acking.

The sender kept iterating over its own sliding window, sending out data
packets at a predefined rate. The packet number was checked in any ACK
that came in (quickly, with the help of the reflected slot number), and if
it was a match, the ACK'd payload and the packet serial number were
evicted from the slot and the slot was refilled from stdin and the
incremented packet counter.

Or something like that.

I wrote it for SUSv1 and it even ran on OpenVMS. Nothing industrial, just
a hobby project that still comes in handy occasionally. If anyone wanted
to take a look, <http://freecode.com/projects/udp_copy2>.

... I'm not saying scatter read was "required", but it felt quite fitting
at the time.

Laszlo
0 new messages