* bytes received from recvmsg doesn't match FIONREAD
@ 2007-10-11 23:08 Steven Dake
2007-10-11 23:35 ` David Miller
2007-10-11 23:36 ` David Stevens
0 siblings, 2 replies; 3+ messages in thread
From: Steven Dake @ 2007-10-11 23:08 UTC (permalink / raw)
To: netdev
I wanted to verify that the size of a multicast UDP message received
with recvmsg matches the size of the message the kernel thinks the
message is.
So I went about using the FIONREAD ioctl as follows:
res = ioctl (fd, FIONCREAD, &value);
assert (res != -1);
bytes_received = recvmsg (fd, &msg_recv, MSG_NOSIGNAL | MSG_DONTWAIT);
assert (bytes_received == value);
It appears the value and bytes_received do not match after many
thousands of runs with a UDP multicast protocol (www.openais.org).
(neither is -1)
Am I using this ioctl improperly? Shouldn't I expect that the full
datagram is returned by recvmsg no matter the state of the blocking or
nonblocking mode of the file descriptor?
pls copy me on responses - i am not onlist.
Regards
-steve
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: bytes received from recvmsg doesn't match FIONREAD
2007-10-11 23:08 bytes received from recvmsg doesn't match FIONREAD Steven Dake
@ 2007-10-11 23:35 ` David Miller
2007-10-11 23:36 ` David Stevens
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2007-10-11 23:35 UTC (permalink / raw)
To: sdake; +Cc: netdev
From: Steven Dake <sdake@redhat.com>
Date: Thu, 11 Oct 2007 16:08:15 -0700
> I wanted to verify that the size of a multicast UDP message received
> with recvmsg matches the size of the message the kernel thinks the
> message is.
>
> So I went about using the FIONREAD ioctl as follows:
>
> res = ioctl (fd, FIONCREAD, &value);
^^^^^^^^^ (typo? should be FIONREAD not FION_C_READ)
> assert (res != -1);
> bytes_received = recvmsg (fd, &msg_recv, MSG_NOSIGNAL | MSG_DONTWAIT);
> assert (bytes_received == value);
I think you want to use SIOCINQ, FIONREAD is only valid on files.
I'm surprised you didn't get an error return from ioctl() as the
VFS code seems to enforce this.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: bytes received from recvmsg doesn't match FIONREAD
2007-10-11 23:08 bytes received from recvmsg doesn't match FIONREAD Steven Dake
2007-10-11 23:35 ` David Miller
@ 2007-10-11 23:36 ` David Stevens
1 sibling, 0 replies; 3+ messages in thread
From: David Stevens @ 2007-10-11 23:36 UTC (permalink / raw)
To: sdake; +Cc: netdev
Questions of this sort should normally be directed to linux-net mailing
list.
>From the code you quoted, I see at least one case where it
will fail -- when the allocated buffer you pass to recvmsg is smaller than
"value" (ie. the datagram is too big for the read buffer).
If that's not the problem, I suggest you reproduce it with a small test
case and post real code and results when it happens.
+-DLS
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-10-11 23:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-11 23:08 bytes received from recvmsg doesn't match FIONREAD Steven Dake
2007-10-11 23:35 ` David Miller
2007-10-11 23:36 ` David Stevens
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).