Path: utzoo!attcan!uunet!lll-winken!sun-barr!newstop!east!witzend!db From: db@witzend.East.Sun.COM (David Brownell) Newsgroups: comp.windows.x Subject: Re: Need Help with mixing RPC and X Message-ID: <1984@east.East.Sun.COM> Date: 2 Jun 90 15:06:35 GMT References: <9005312234.AA18852@viking.frame.com> Sender: news@east.East.Sun.COM Reply-To: dave.brownell@.East.Sun.COM (David Brownell) Organization: Sun Microsystems, Billerica MA Lines: 41 Re the question of how to get an X (Xt) application to act as an RPC server (client is no issue), dpb@viking.frame.com (Don Bettnet) writes: >> 1. The ability to tell XtMainLoop to look for an RPC request while >> looking for X events, and have it call an appropriate callback. >> > >How about this? Works for me.... > Solution deleted to avoid clutter: it used XtAppAddInput() > to install an input callback on the file descriptor used by > the service transprot handles: SVCXPRT *t; fd = t->xp_sock. > The input callback invoked svc_getreq() to handle the call. It's worth noting that this posted solution works only for UDP RPCs. That is, if you use TCP for simpler semantics, more data than the default of 8 Kbytes, or better error reporting, this doesn't work. Also, this uses the obsolete svc_getreq() call, which is limited to 32 file descriptors. More recent UNIXes have a much higher limit -- this should use svc_getreqset() instead, which handles many more file descriptors. The issue with TCP is that the RPC library needs to allocate and deallocate file descriptors dynamically. To handle this within Xt, the input callback for the tcp-based SVCXPRT must diff the RPC file descriptors in svc_fdset before and after it calls svc_getreqset(), invoking XtAppAddInput (or XtAddInput) on new file descriptors and calling XtRemoveInput() one ones that've disappeared. The upcoming release of XView will do this for you automatically if you ask, so that you won't have to scour the innards of the window system and notifier documentation to find out how to do this! David Brownell db@east.sun.com. Sun Desktop Systems Software (508) 671-0348 "We'll get to ISO, Mars, and Pluto ... not necessarily in that order."