tomas@m2cs.uu.no (Tomas Felner) (07/18/89)
I have spent some time trying to find a solution to the following problem, but I haven't succeed yet. I hope someone on the net can help me. I have a server and a client process, connected through sockets. The server process sometimes sends a couple of characters to the client, which should read them from the server in turn. The client, however, mainly reads from the keyboard (stdin), and should read from the server only when characters are available. Each of those read routines is embedded in a lightweight process. When such a process does a read (not using the read(2) call !!), it checks if there is something available by calling 'select'. If there is nothing to be read, it transfers control to another ready LW process. If there are no ready LW processes around, it blocks by calling 'sigpause'. The whole mechanism is unblocked by typing something on the keyboard or by sending some characters from the server to the client. Having enabled asynchronous IO on stdin and on the connection to the server, this should cause a SIGIO, thereby terminating sigpause, making the appropriate LW process runnable and finally run it. I know that I could use 'select' instead of 'sigpause' to poll all inputs in order to find out if something is available. However, I consider the solution with asynchronous IO and sigpause much more elegant, and I am willing to do polling only if there is absolutely no way of doing it asynchronously. Those lightweight processes are not the same supplied with SunOS 4.0. They are part of a selfmade library, completely programmed in Modula-2. I enable asynchronous IO on stdin and the connection to the server by calling 'ioctl', passing FIOASYNC from <sys/filio.h> as request and 1 as arg. This works fine for stdin, where I get lots of SIGIO signals from, but it doesn't seem to have any effect on the connection to the server. I also tried to use 'fcntl', passing F_SETFL as cmd and FASYNC as arg, but no effect. I was told that there was a bug with async. IO in SunOS 4.0, and that I have to reset the signal vector every time after I have received a SIGIO. This seems to be correct, since after I got the first SIGIO from stdin, I don't get any more SIGIOs if I don't reinstall the vector after each occurence of it. But this 'bug fix' doesn't help when it comes to the socket connection between server and client. I am desperately trying to get a SIGIO signal from the connection to the server. I know that characters are being sent from the server to the client, and when I go look for them by other means than getting a signal I can happily read them. I'm not sure if I am doing something wrong, if I'm missing something or if this is just another bug of SunOS 4.0. PLEASE HELP !!!! Thanks, Tomas Tomas Felner Modula-2 CASE Systems AS | Internet: tomas@m2cs.uu.no Maridalsveien 139 | Phone1: +47 2 379784 N-0461 Oslo 4, Norway | FAX: +47 2 356448