Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!aramis.rutgers.edu!paul.rutgers.edu!pilot.njin.net!princeton!udel!haven!ames!rex!rouge!gator.cacs.usl.edu From: pcb@gator.cacs.usl.edu (Peter C. Bahrs) Newsgroups: comp.unix.questions Subject: RE: interrupt driven sockets Message-ID: <4597@rouge.usl.edu> Date: 27 Feb 90 08:28:13 GMT Sender: anon@rouge.usl.edu Distribution: usa Organization: The Center for Advanced Computer Studies, USL Lines: 47 > >I am currently struggling with sockets under SUNOS 3.5. The basic problem is >trying to implement interrupt driven I/O rather than use the select call >which I can't use because of other activity within the same process. > >The current state of play is that I've succeeded in arranging to have the >arrival of data at a socket signalled by SIGIO. This was done using the usual >incantations for setting the owner of the socket to be the process group of >the process to which the socket belongs, making the socket non-blocking and >setting its ASYNC flag. > >The problem arises because if I write to a socket and get back an EWOULDBLOCK >error I have no way of knowing, other than polling, when the socket again >becomes writable. I had hoped that when the state of the socket changed from >blocked to unblocked that a SIGIO would be generated but from my experiments >this appears not to be the case. Well... I just got through working on this problem, for the time being as I haven't completely solved it. My applications used a regular and interrupt socket. It is my understanding that if an interrupt occurs, some system calls will return and error (i.e. -1 for read, write, accept,...). This means that ?EVERY? system call must be checked as in: while (-1 == specific_system_call(...)) { if (errno == EINTR) continue; else; } good part here... This expands in the errno == part to things like ETIMEDOUT, Ewhatever. So if I am waiting for a read and and interrupt occurs on the other socket, I will process the other through the handler, return and read will fail, but I realize it was due to an interrupt, hopefully the one I just processed??, and retry the read. Someone please tell me if this is correct. /*----------- Thanks in advance... --------------------------------------+ | Peter C. Bahrs | | The USL-NASA Project | | Center For Advanced Computer Studies INET: pcb@gator.cacs.usl.edu | | 2 Rex Street | | University of Southwestern Louisiana ...!uunet!dalsqnt!gator!pcb | | Lafayette, LA 70504 | |------------------------------------------------------------------------| +-- He who is afraid of asking is ashamed of learning - Fortune Cookie -*/