Re: select() and DGRAM

From: Andi Kleen (
Date: Fri Jun 16 2000 - 11:00:29 EST

On Fri, Jun 16, 2000 at 04:20:40PM +0200, Tomas Pihl wrote:
> I'm playing with a UDP-based program and I stumbled into something I
> can't understand. What I'm doing is:
> o Make a SOCK_DGRAM socket
> o bind() the socket to INADDR_ANY and port = 0 (port will
> be assigned by the system)
> o FD_ZERO and FD_SET(sockfd, readset)
> o Send some data to "" at port 18190 with sendto() using
> the same socket just created
> o Do a select() on the readset
> At this stage, select() fires and FD_ISSET indicates something is on
> the socket. But I haven't sent anything to that port. Only to port
> 18190. Trying to revfrom() on the socket returns -1.
> On Linux 2.0.34 (glibc2.0.7) and 2.2.14 (glibc2.1.3) the above will
> happen. I've also tried this on SunOS 5.6 and NetBSD 1.4.1 which
> doesn't show this behaivour. Am I just too tired and missed something
> or it this the way it should be?

You got an error on the socket (probably ICMP port unreachable) and the
socket has an error set. Error set translates to select readable -- in
poll it would be a POLLERR. NetBSD/solaris do not report asynchronous
errors on unconnected datagram sockets, Linux does. See udp(4)
for details.


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
Please read the FAQ at

This archive was generated by hypermail 2b29 : Fri Jun 23 2000 - 21:00:12 EST