Subject: Portability of ioctl(FIONREAD) betwix NetBSD and Linux
To: NetBSD Users <>
From: B. James Phillippe \(nospam address\) <>
List: netbsd-users
Date: 01/22/2002 16:37:29

I'm debugging an application which calls ioctl(fd, FIONREAD,
(char*)&nread) on a unix domain socket, and then sanity-checks that nread
== the expected number of bytes.  On Linux, the number of bytes returned in
nread is exactly equal to the number of bytes written to the socket.  On
NetBSD/Alpha, the number returned is equal to the number written + 106.  It
seems that many implementations of ioctl(FIONREAD) return the number of
bytes available + sizeof(sockaddr) for SOCK_DGRAM sockets.  I have a couple
questions about all this:

1.) I'm trying to find a definitive resource that states what you can and
cannot assume about the results of ioctl(FIONREAD).

2.) I'm curious to know where the 106 bytes comes in.  I took a quick look
through some of the NetBSD kernel source, and I can only account for 16 of
those bytes.

thanks for any info,
# bryan at darkforest dot org
# Software Architect