Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!ncar!mailrus!tut.cis.ohio-state.edu!rutgers!bellcore!dana From: dana@dino.bellcore.com (Dana A. Chee) Newsgroups: comp.windows.x Subject: Re: HELP! (sockets/X) Message-ID: Date: 22 Aug 88 13:08:02 GMT References: <80100001@convex> Sender: news@bellcore.bellcore.com Organization: Bellcore, Morristown, NJ USA Lines: 42 In-reply-to: cuddy@convex.UUCP's message of 27 Jul 88 09:57:00 GMT In article <80100001@convex> cuddy@convex.UUCP writes: Here's a question for all you X11R2 wizards: I'm writing a program that does a select on a socket to wait for data from a daemon program. It also needs to look for events from the X server (exposes, mouse clicks, etc.). I really don't want to do a non blocking select, check if there are X events and then go back to sleep. I'm a novice 'X' programmer: is there something I'm missing? Yes, you can add the X file descriptor to your select call. It is obtained by: Xfd = ConnectionNumber(display); where 'display' is the display returned from your XOpenDisplay(). Now, when your select returns, you test to see which file descriptor has data. readfiles = (1 << yourSocket) | (1 << Xfd ); n = select(32, &readfiles, 0, 0, 0); if( readfiles & (1 << Xfd) ) { XNextEvent(dpy, &event); . . . } else { /* whatever you wish with your socket */ } Hope this helps. -- +*************************************************************************+ * Dana Chee (201) 829-4488 * * Bellcore * * Room 2Q-250 * * 445 South Street ARPA: dana@bellcore.com * * Morristown, NJ 07960-1910 UUCP: {gateways}!bellcore!dana * +*************************************************************************+