@lay:4468l3 Listing 3. Using an Exception Set void getdata(int ixj1) { fd_set rfds,wfds,efds; struct timeval tv; union telephony_exception ixje1; int nmax, size, state, nlen; char buf[480], jbuf[480], dtmf1; char date[5], time[5], clen[2], pnum[11], cname[80]; nmax = ixj1+1; /* clear the file descriptor sets */ FD_ZERO(&rfds); FD_ZERO(&wfds); FD_ZERO(&efds); /* set them all to include our descriptor ixj1 */ FD_SET(ixj1, &rfds); FD_SET(ixj1, &wfds); FD_SET(ixj1, &efds); /* set the timeout for select to be quite short */ tv.tv_sec = 0; tv.tv_usec = 300; /* block for the time period or until activity occurs on the file descriptor */ select(nmax, NULL, &wfds, &efds, &tv); if(FD_ISSET(ixj1,&wfds)) { /* the file descriptor is ready for writing - send it some data! */ } if(FD_ISSET(ixj1,&rfds)) { /* the file descriptor is ready for reading - read some data! */ } if(FD_ISSET(ixj1,&efds)) { /* ask the device what kind of exception occurred */ ixje1.bytes = ioctl(ixj1, PHONE_EXCEPTION); /* check to see if the user hung up or picked up the phone */ if(ixje.bits.hookstate) { if(ioctl(ixj1, PHONE_HOOKSTATE)) { printf("Off Hook\n"); } else printf("On Hook\n"); } } }