home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.protocols.nfs:2253 comp.os.ms-windows.programmer.misc:1704
- Path: sparky!uunet!wupost!sdd.hp.com!network.ucsd.edu!munnari.oz.au!mel.dit.csiro.au!yarra!bohra.cpg.oz.au!als
- From: als@bohra.cpg.oz.au (Anthony Shipman)
- Newsgroups: comp.protocols.nfs,comp.os.ms-windows.programmer.misc
- Subject: Implementing an RPC server with PC-NFS
- Message-ID: <1992Sep7.063013.25325@bohra.cpg.oz.au>
- Date: 7 Sep 92 06:30:13 GMT
- Organization: Computer Power Software
- Lines: 97
-
- I have the PC-NFS 4.0 Programmer's Toolkit. It omits the server side of the
- ONC RPC package. But I need to write an application that runs as an RPC
- server under Windows 3.1.
-
- Here is my proposal for how to do this. I have the source for TIRPC V2.0beta
- so I can compile the server code under Windows. The only tricky thing I expect
- is emulating the behaviour of the Unix poll() system call. There must be a
- task switch while waiting for a network packet so there must be a message
- loop. There is no way to get a message when an
- RPC packet comes in so I have to poll the network periodically.
- I can do this with a Windows timer. I run a message dispatch
- loop. When a timer message comes in I check for RPC packets. If one is found
- then the message loop is terminated and the poll() function returns.
-
- Here is pseudo-code for the scheme:
-
-
- int
- RunMessageLoop( int (*done_proc)(void), void *arg)
- {
- /*
- ** Return TRUE only if we exited because done_proc() succeeded.
- */
- int ret = FALSE;
-
- do()
- {
- ret = (*done_proc)(arg); /* do first in case already ready */
- if (ret)
- break;
-
- GetMessage()
- DispatchMessage()
-
- any other Windows-specific break condition
- }
- }
-
-
- An implementation of poll() for the server library must do the following.
-
- svc_poll(poll_set, npoll, timeout)
- {
- int done;
- struct arg;
-
- clear timeout counter
- build arg from poll data and timeout counter
-
- done = RunMessageLoop(check_for_any_ready_fds, arg);
-
- if (done)
- {
- unpack data into poll_set
- return OK
- }
- else
- {
- return some error /* application window dying? */
- }
- }
-
- int
- check_for_any_ready_fds(arg)
- {
- if (any fds in *arg ready)
- {
- build the set of ready fds in *arg
- return true
- }
- inc arg->timeout counter
- if (timeout exceeded)
- {
- flag timeout in *arg
- return true
- }
- return false
- }
-
- I can use select() with a 0 timeout to check for ready fds.
-
- Does this scheme seem reasonable? Can anyone suggest a better way to do this.
-
- There are other complications of course. My server must include an emulation
- of rpcbind. This means the server code must listen for rpcbind packets as well
- as application packets and distribute them. The rpcb_set() and rpcb_unset()
- functions need to be reimplemented to call rpcbind() locally since it will be
- linked in with the server library.
-
-
- Thanks for any advice.
-
- --
- Anthony Shipman "You've got to be taught before it's too late,
- CP Software Export Pty Ltd, Before you are six or seven or eight,
- 19 Cato St., East Hawthorn, To hate all the people your relatives hate,
- Melbourne, Australia, 3121 You've got to be carefully taught." R&H
-