majumdar@bgsuvax.UUCP (anindo Majumdar) (03/14/91)
Is there anyway an interrupt can be sent to a program whenever a message intended for it arrives on a socket?Is there a standard signal available in Berkeley 4.2 BSD Unix for such an interrupt ?Basically I do not want to wait on a recvfrom call.At the same time I would like to handle any messages.(A recvfrom call with a non blocking option set doesn't help as it returns an error E_WOULDBLOCK if there are no messages when the recvfom is executed).Any pointers will be appreciated. Internet : majumdar@andy.bgsu.edu
hlh@raybed2.msd.ray.com (HOWARD HANTMAN) (03/16/91)
In article <7134@bgsuvax.UUCP>, majumdar@bgsuvax.UUCP (anindo Majumdar) writes: > Is there anyway an interrupt can be sent to a program whenever a message > intended for it arrives on a socket?Is there a standard signal available in > Berkeley 4.2 BSD Unix for such an interrupt ?Basically I do not want to wait > on a recvfrom call.At the same time I would like to handle any messages.(A recvfrom call with a non blocking option set doesn't help as it returns an error > E_WOULDBLOCK if there are no messages when the recvfom is executed).Any pointers will be appreciated. Using fcntl's it is possible to mark a file descriptor as being asynchronous. When this is done, a SIGIO signal (or SIGURG for out of band urgent data) is sent to the process or process group receiving such signals whenever IO is possible on the descriptor. To set the descriptor to be asynchronous, get the current flags using the F_GETFL fcntl. OR in the FASYNC flag and set them back using F_SETFL. To set the process/process group to receive the signals use F_SETOWN. If the argument is negative it is used as a process group, otherwise it is used as a process id. While my experience is actually with Ultrix, I believe this is available on any Berkeley based system. I have seen some systems, including older Ultrix systems, however, where FASYNC is available only if the descriptor references a tty. Howard Hantman Computing Consultant Software Development Center Raytheon Co. hlh@swlvx2.msd.ray.com ...{linus,applicon,cg-atla}!raybed2!hlh