Polling on a socket without select()...

matt robinson yakker at ucrmath.UCR.EDU
Fri Nov 10 12:56:45 AEST 1989


In article 2065, micky at cunixc.cc.columbia.edu (Micky Liu) writes:
 
>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...

You could set the ioctl to non-blocking without having to check the socket
just once, but if you are looking for the long run, I would suggest using
select to check for data, especially if you are looking to delay for any
length of time, and would like to repeat the procedure.

---------------------------------------*--------------------------------------
"Behold, God, is my salvation, I       |   Internet:    yakker at ucrmath.ucr.edu
will trust, and not be afraid.."      |+|      UUCP:    ...ucsd!ucrmath!yakker
                                     |+|+|          
"What lies behind you and what lies  |+|+|        The University of California
before you pales insignificant when   |+|                         at Riverside
compared to what lies within you.."    |        Department of Computer Science
---------------------------------------*--------------------------------------



More information about the Comp.unix.questions mailing list