select() and DGRAM

From: Tomas Pihl (
Date: Fri Jun 16 2000 - 09:20:40 EST

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?


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:11 EST