home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.windows.x:15144 comp.windows.x.apps:761 comp.windows.x.intrinsics:179
- Newsgroups: comp.windows.x,comp.windows.x.apps,comp.windows.x.intrinsics
- Path: sparky!uunet!wupost!uwm.edu!daffy!uwvax!zazen!news
- From: daerb@vms.macc.wisc.edu (David Erb)
- Subject: Summary: how to wake up XNextEvent for pipe/socket input pending?
- Message-ID: <1992Aug12.114223.24329@macc.wisc.edu>
- Sender: news@macc.wisc.edu (USENET News System)
- Organization: University of Wisconsin Academic Computing Center
- Date: 12 AUG 92 06:39:25
- Lines: 83
-
- Original text of query follows responses.
-
- Responses were:
-
- 1. See Bloomer, J, "Power Programming with RPC" O'Reilly & Associates.
-
- 2. Use Intrinsics Toolkit XtAppAddInput.
-
- 3. Put display->fd in select with socket of interest (not recommended).
-
- 4. Same but use ConnectionNumber(display) not display->fd.
-
- 5. A forked child should not have the same display connection as the parent.
-
- 6. Signals and X do not mix terribly well.
-
- 7. There's been a lot of traffic in this group about NOT doing Xlib or
- any X thing inside a signal handler.
-
- 8. XNextEvent will get interrupted, but since the X libraries
- are not reentrant, you won't like the results...
-
- Thanks and gratitudes to all who replied. Hope I didn't forget anyone.
-
- nh@cbnewsg.cb.att.com
- jhd@irfu.SE
- david@ora.com
- jrutledg@cs.ulowell.edu
- dob@inel.gov
- janzen@mprgate.mpr.CA
- bateman@cs.utk.edu
- eldred@hare.udev.cdc.com
- gnb@bby.com.AU
-
- ----------------------------------------------------------
-
- Original text of query was:
-
- How do I get XNextEvent to wake up when input has
- become available on some pipe (fifo) or socket? As far
- as I can tell, Xlib only wakes up on a fixed set of
- user-oriented events which does not include input pending.
-
- I hope there is an elegant solution! Any help would be
- greatly appreciated. Please respond by e-mail and I will
- post a summary. Thanks in advance.
-
- Dave
-
- Background: I have a bunch of programs which do all their
- plotting by sending messages over sockets to a central
- plotting server. I'd like this plotting server to control
- an X window. While the plotting server is sitting there
- waiting for regular X events, such as mouse, keyboard, and
- expose, I'd also like the plotting server to be able to
- respond to drawing requests over the socket. For those
- who know SunView, the analogy would be notify_set_input_func().
-
- A bunch of yucky solutions come to mind:
-
- Yucky solution number 1:
- Open the window and the socket, then fork, with the parent
- putting a select() on the socket, and the child doing a
- normal XNextEvent() loop. When the socket has data,
- the parent then does an XSendEvent() to the window. The
- child doing the XNextEvent() wakes up on the event from
- the parent, then reads the socket to get the plotting
- requests.
-
- Yucky solution number 2:
- Use the operating system's asynchronous I/O option to take
- a SIGIO signal when input is pending. Limited to those
- OS's with asynchronous I/O.
-
- Yucky solution number 3:
- Use alarm to get a SIGALRM every one second and check the
- input socket for data. Thus the XNextEvent loop works
- normally except it gets alarmed every second and data
- gets plotted from the signal handler. Does Xlib do
- some things during plotting that are illegal for signal
- handlers? Does XNextEvent even get interrupted by signals
- such as SIGALRM?
-
-