Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!hplabs!hpfcdc!hpfcmr!chan From: chan@hpfcmr.HP.COM (Chan Benson) Newsgroups: comp.windows.x Subject: Re: Re: XSelectNextEvent() Message-ID: <1210010@hpfcmr.HP.COM> Date: 13 Mar 89 20:37:56 GMT References: <134@mirsa.inria.fr> Organization: HP Fort Collins, CO Lines: 18 >> I want to wait for X events from more than one X server. >> (it's for a communication program named xtalk, which act >> basically like the unix-talk but with the X protocol and >> windows/mouse convenience: independent window, drawing facility, >> talk with several persons...) > >I'd say that this application is a good candidate for >multi-processing. You have two asynchronous event sources. If you >try to deal with them both in one (synchronous) process, you will >either spend a lot of time in pointless looping (which is expensive of >CPU time) or block on one event source while ignoring input on the >other (which increases response time). I'd suggest you fork() two >processes, one to watch each display, which communicate with each >other via pipes or shared memory. If you've got the select system call, you can multiplex input easily. You will end up holding up the other input source for as long as it takes you to respond to the other one, but it won't be ignored forever.