Questions on asynchronous I/O with sockets

Costello costello at mbunix.mitre.org
Wed Jan 23 03:40:36 AEST 1991


Hello, I have a couple of questions on doing aynchronous I/O on sockets
(1) I have set up a socket to do asynchronous I/O as follows:
           s = socket(AF_UNIX, SOCK_STREAM, 0);
           fcntl(s, F_SETOWN, getpid());
           fcntl(s, F_SETFL, FASYNC);
    I am finding that during this process a SIGIO signal is
    generated. My first question, then, is: is this normal?
    Should I get a signal when I set up a socket?

(2) I have this socket (s) connected to a socket on the same
    machine. Let me refer to the process that contains "s" as
    the client process and the other process to which it is 
    connected as the server process. The client process and
    the server process are exchanging messages back and forth.
    I have made "s" asynchronous so that the client can do
    other work while it waits for a message to come from the
    server and then when the SIGIO arrives it interrupts the
    client which then reads "s". 
    I have observed that I am getting many more SIGIOs than I
    had anticipated. I thought that I would only get a SIGIO
    when data arrived on the socket, "s" (ie. when the client
    got data from the server). Well, I seem to be also getting
    SIGIO when the client sends data to the server. My question,
    then, is twofold:
       (a) FASYNC is supposed to allow asynchronous "I/O". I
           guess that I have always been thinking along the
           lines of asynchronous (I)nput and not asynchronous
           (O)utput. Does asynchronous Ouput mean that when
           I write on "s" a SIGIO is automatically generated?
           What does it mean to do asynchronous output? 
           Asynchronous input buys me the ability to do
           other work instead of waiting on a read statment.
           What does asynchronous output buy me?
           A SIGIO being generated whenever I do a write on "s"
           would account for all the extra SIGIO signals that I
           am seeing.
       (b) As an alternative explanation to why I am getting
           the extra SIGIOs I thought that perhaps when I set
           up "s" to be an asynchronous I/O socket then the
           socket to which it connected to would "inherit"
           this asynchronicity characteristic. So, when the
           server received a message from the client then a
           SIGIO would be generated. So, my question is:
           if "s" is asynchronous then does the socket to 
           which it is connect automatically become asynchronous?


I am working on an Apple IIx running A/UX 1.1.1.
Any insights that ya'll could provide would be much 
appreciated. Please e-mail to me: costello at mitre.org
Thanks. Cheers! /Roger



More information about the Comp.unix.questions mailing list