Subject: Re: sendto(2) EINVAL / pacing problem
To: None <tech-net@NetBSD.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-net
Date: 02/09/2004 15:27:22
> A state query client asks over a Unix Domain UDP Socket

Ummm...strictly speaking, there is no such thing; UDP is used for
AF_INET and AF_INET6, but not AF_LOCAL (nee AF_UNIX).

Do you mean AF_LOCAL/SOCK_DGRAM (ie, "Unix Domain" datagram), or
AF_INET/SOCK_DGRAM (UDP)?  Based on what clues I see in the code you
quote, I assume it's the former.

> - How do I go about pacing sendto(2) on a non-blocking socket?

I usually use select()/poll() to check that the socket shows writeable
before trying to write.

> - Is sendto(2) giving me a misleading/wrong error message? 

Almost certainly; it really should be returning EWOULDBLOCK, or at the
very least ENOBUFS.  EINVAL's semantics are pretty definitely wrong.
(Actually, if you can, you might try using a connected socket; you
might get EWOULDBLOCK that way.)

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML	       mouse@rodents.montreal.qc.ca
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B