Path: utzoo!utgpu!water!watmath!clyde!rutgers!rochester!udel!gatech!mcnc!rti!trt From: trt@rti.UUCP (Thomas Truscott) Newsgroups: comp.unix.wizards Subject: Re: Efficiency of detecting input FD after SIGIO? Keywords: SIGIO, socket, select, ioctl Message-ID: <2023@rti.UUCP> Date: 8 Feb 88 16:25:12 GMT References: <108@titan.SW.MCC.COM> Organization: Research Triangle Institute, RTP, NC Lines: 22 In <108@titan.SW.MCC.COM>, janssen@titan.SW.MCC.COM (Bill Janssen) writes: > I have a program that has between 1 and 20 sockets open. > It receives SIGIO when input is available on some one of them. > 80% of the time there is only one open socket. > Given this, what is the most efficient way to tell what fd the input > is available on? Well, it sounds like 80% of the time you *know* what fd the input is available on, so you can just read the data (you might consider non-blocking I/O). If there is more than one fd just use select(). Calls like select() are why BSD is so much better than System V. But if you can't resist optimizing things, do a (non-blocking) read of the fd you think has the data. If it indeed has data you avoid the overhead of the select(). I find signal handling to be a dangerous business, and recommend against it. Do you really need SIGIO? What is the program doing in the meantime? If it is just reading from a terminal, put the select() on that as well and you win all around. Tom Truscott