home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / protocol / nfs / 2253 < prev    next >
Encoding:
Internet Message Format  |  1992-09-08  |  3.2 KB

  1. Xref: sparky comp.protocols.nfs:2253 comp.os.ms-windows.programmer.misc:1704
  2. Path: sparky!uunet!wupost!sdd.hp.com!network.ucsd.edu!munnari.oz.au!mel.dit.csiro.au!yarra!bohra.cpg.oz.au!als
  3. From: als@bohra.cpg.oz.au (Anthony Shipman)
  4. Newsgroups: comp.protocols.nfs,comp.os.ms-windows.programmer.misc
  5. Subject: Implementing an RPC server with PC-NFS
  6. Message-ID: <1992Sep7.063013.25325@bohra.cpg.oz.au>
  7. Date: 7 Sep 92 06:30:13 GMT
  8. Organization: Computer Power Software
  9. Lines: 97
  10.  
  11. I have the PC-NFS 4.0 Programmer's Toolkit.  It omits the server side of the
  12. ONC RPC package.  But I need to write an application that runs as an RPC
  13. server under Windows 3.1.
  14.  
  15. Here is my proposal for how to do this.  I have the source for TIRPC V2.0beta
  16. so I can compile the server code under Windows.  The only tricky thing I expect
  17. is emulating the behaviour of the Unix poll() system call.  There must be a
  18. task switch while waiting for a network packet so there must be a message 
  19. loop.  There is no way to get a message when an 
  20. RPC packet comes in so I have to poll the network periodically. 
  21. I can do this with a Windows timer.  I run a message dispatch
  22. loop.  When a timer message comes in I check for RPC packets.  If one is found
  23. then the message loop is terminated and the poll() function returns.
  24.  
  25. Here is pseudo-code for the scheme:
  26.  
  27.  
  28. int
  29. RunMessageLoop( int (*done_proc)(void), void *arg)
  30. {
  31.     /*
  32.     **  Return TRUE only if we exited because done_proc() succeeded.
  33.     */
  34.     int ret = FALSE;
  35.  
  36.     do()
  37.     {
  38.         ret = (*done_proc)(arg);     /* do first in case already ready */
  39.         if (ret) 
  40.             break;
  41.  
  42.         GetMessage()
  43.         DispatchMessage()
  44.  
  45.         any other Windows-specific break condition
  46.     }
  47. }
  48.  
  49.  
  50. An implementation of poll() for the server library must do the following.
  51.  
  52. svc_poll(poll_set, npoll, timeout)
  53. {
  54.     int     done;
  55.     struct  arg;
  56.  
  57.     clear timeout counter
  58.     build arg from poll data and timeout counter
  59.  
  60.     done = RunMessageLoop(check_for_any_ready_fds, arg);
  61.  
  62.     if (done)
  63.     {
  64.         unpack data into poll_set
  65.         return OK
  66.     }
  67.     else
  68.     {   
  69.         return some error   /* application window dying? */
  70.     }
  71. }
  72.  
  73. int
  74. check_for_any_ready_fds(arg)
  75. {
  76.     if (any fds in *arg ready)
  77.     {
  78.         build the set of ready fds in *arg
  79.         return true
  80.     }
  81.     inc arg->timeout counter
  82.     if (timeout exceeded)
  83.     {
  84.         flag timeout in *arg
  85.         return true
  86.     }
  87.     return false
  88. }
  89.  
  90. I can use select() with a 0 timeout to check for ready fds.
  91.  
  92. Does this scheme seem reasonable?  Can anyone suggest a better way to do this.
  93.  
  94. There are other complications of course.  My server must include an emulation
  95. of rpcbind.  This means the server code must listen for rpcbind packets as well
  96. as application packets and distribute them.  The rpcb_set() and rpcb_unset()
  97. functions need to be reimplemented to call rpcbind() locally since it will be
  98. linked in with the server library.
  99.  
  100.  
  101. Thanks for any advice.
  102.  
  103. -- 
  104. Anthony Shipman                 "You've got to be taught before it's too late,
  105. CP Software Export Pty Ltd,      Before you are six or seven or eight,
  106. 19 Cato St., East Hawthorn,      To hate all the people your relatives hate,
  107. Melbourne, Australia, 3121       You've got to be carefully taught."  R&H
  108.