Polling on a socket without select()...

Joseph C. Konczal konczal at mail-gw.ncsl.nist.gov
Fri Nov 10 03:50:28 AEST 1989


| I am writing a program that needs to effect a poll on a udp/ip socket.  I am
| using recvfrom(2) to read data, but I would like it to return immediately if
| there is no data ready...  My SunOS4.x man page says that there is a method
| to make the recvfrom() call return immediately using ioctl(2) to set the
| socket to non-blocking...  I have looked in <sys/ioctl.h> and <sys/sockio.h>
| but have not found any ioctl capable of doing this...
| 
| I know of the method using select(2), but that seems like overkill if I only
| have one socket, it is not really a selection process...  Is there something
| in a man page someplace that would explain this in some more detail or is it
| a man page error?
| 
| Thanx!
| 
| Micky
| 
|   arpa: micky at cunixc.cc.columbia.edu
|   uucp: ...!rutgers!columbia!cunixc!micky
| bitnet: malua at cuvmc

It seems like a strange place for this information, but the socket(2)
man page refers you to fcntl(2v) where under F_SETFL it tells you that
using fcntl to set a certain flag will cause the desired ioctl to be
performed...  So look up FIONBIO in filio(4).

Joe
internet: konczal at mail-gw.ncsl.nist.gov



More information about the Comp.unix.questions mailing list