konczal@mail-gw.ncsl.nist.gov (Joseph C. Konczal) (11/10/89)
| 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@cunixc.cc.columbia.edu | uucp: ...!rutgers!columbia!cunixc!micky | bitnet: malua@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@mail-gw.ncsl.nist.gov
yakker@ucrmath.UCR.EDU (matt robinson) (11/10/89)
In article 2065, micky@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@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 ---------------------------------------*--------------------------------------