home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / next / programm / 7987 < prev    next >
Encoding:
Internet Message Format  |  1993-01-05  |  5.5 KB

  1. Path: sparky!uunet!psinntp!sugar!tghost!unkaphaed!biff!biff
  2. From: biff@biff.gbdata.com (Dwight Everhart)
  3. Newsgroups: comp.sys.next.programmer
  4. Subject: Re: Sending objects between processes (SUMMARY)
  5. Summary: Distributed objects are the way to go.
  6. Keywords: distributed objects, typed streams, speaker listener
  7. Message-ID: <C0DBDC.1n7@biff.gbdata.com>
  8. Date: Tue, 5 Jan 1993 06:29:35 GMT
  9. References: <C03x19.Jx2@biff.gbdata.com>
  10. Sender: biff@biff.gbdata.com (Dwight Everhart)
  11. Lines: 98
  12.  
  13. In article <C03x19.Jx2@biff.gbdata.com> I wrote:
  14. > I'm writing a software system involving a server process and several client  
  15. > processes.  I'm writing them in Objective-C, although the server is a
  16. > daemon, not an application (it doesn't have a NXApp).  The clients may or
  17. > may not be applications.  I'm using Speaker and Listener objects for the
  18. > RPC requests.
  19. > I need to be able to send objects between the clients and the server.
  20. [Description of first approach deleted.]
  21. > My second (and latest) approach is to use typed streams on ports, and send  
  22. > the objects using NXWriteObject() and NXReadObject().
  23.  
  24. I ended up using a typed stream on a memory buffer, and then sending the  
  25. buffer to the other process through a block in a Speaker/Listener message.  I  
  26. switched to buffers because of an interesting problem I had with ports.  I  
  27. was keeping the typed stream open and sending several objects through it.   
  28. However, when the stream was read, only the first object was returned, no  
  29. matter how many times it was read or how many objects were written to it.   
  30. Apparently only one object can be sent over one typed stream.
  31.  
  32. The solution was to open a typed stream for each object.  Since I wanted to  
  33. minimize the amount of code I had to write, I switched to buffers.  NeXT  
  34. already provides a function, NXWriteRootObjectToBuffer(), that allocates the  
  35. buffer, opens the typed stream on it, writes the object, truncates the  
  36. buffer, and closes the stream -- all in one function!  There isn't an  
  37. equivalent function for ports.
  38.  
  39. The system seems to be working now, although I am not sure who should be  
  40. freeing the memory buffer sent through the Speaker/Listener message.  The  
  41. manual says that NXFreeObjectBuffer() should be called to free the buffer  
  42. when it is not needed anymore.  However, the same manual says that blocks  
  43. sent in Speaker/Listener messages are automagically freed.  So who frees  
  44. memory buffers created by NXWriteRootObjectToBuffer() and sent through a  
  45. Speaker/Listener message?
  46.  
  47. As I said in my previous article, I'm not using distributed objects because  
  48. I'm running 2.0.  I'm hesitant about upgrading to 3.0 because of it's  
  49. performance impact (I have an '030 cube) and its bugs.
  50.  
  51.  
  52. > If you know of a better way to send objects between processes, please  
  53. > explain.  I'm running 2.0, so I don't have distributed objects.  Do they  
  54. > offer a better approach?
  55.  
  56. Three people replied, and they all suggested distributed objects.
  57.  
  58.  
  59. Montgomery Zukowski <monty@intuitiveedge.com> writes:
  60.  
  61. >         I think that sending objects over typed streams will work fine as
  62. > long as you also send the class to be dynamically loaded, probably easiest
  63. > to send the filename of the modules to link in, although for security you
  64. > might want to send the object data itself.
  65. >         Even distributed objects in 3.0 requires that the classes of
  66. > objects be loaded in the recieving progrtamm so that copies can be
  67. > instantiated when they are recieved.  Distributed Objects does have a
  68. > transport protocol which specifies how to encode and decode objects which
  69. > are passed between programs, you might want to look at it for ideas.  It is
  70. > needed because some objects passes may be distributed objects while others
  71. > are going to be copied and instantiated.  If you don't need to maintain
  72. > connections accross programs, then you don't really need distributed
  73. > objects.  From your description you seem to only need to pass objects and
  74. > not maintain a connection to the server's objects.
  75.  
  76.  
  77. Timothy J. Wood <bungi@u.washington.edu> writes:
  78.  
  79. >   Yes!  They handle everything for you (except making sure the class in
  80. > linked in).  For example, say I have two processes, A and B.  A has a list,
  81. > and B has some items that it wishes to put in A's list.  A would simply
  82. > 'vend' the object (two lines of code).  B would look up the vended object
  83. > (one line of code which returns an id).  B could then treat that id exactly
  84. > like it was the real object since all messages to it would be bundled up
  85. > and transmitted to the real object.  When B sends it's object id's to the
  86. > proxy for A's list, it could specify to send a copy, rather than the whole
  87. > object.
  88. >   I would strongly suggest that you take a look at Distributed Objects.
  89. > They are by far the coolest thing that NeXT has done in version 3.0.
  90.  
  91.  
  92. Paul Burchard <burchard@localhost.gw.umn.edu> writes:
  93.  
  94. > Distributed Objects is the best way to do all this stuff, even with  
  95. > the extra twist of dynamic loading.  You can do what you want, with  
  96. > fine control over freeing responsibilities and good transparency to  
  97. > the rest of the code, using the NXTransport protocol (one of the  
  98. > highlights of D.O.).  Check it out and ask me if you need more  
  99. > info...
  100.  
  101.  
  102. Thanks to all who responded.  Although distributed objects sound good, I'll  
  103. use typed streams for now, since I have them working, and I don't have 3.0.
  104.  
  105. --
  106. Dwight Everhart          "Spring will come for IBM when people
  107. Houston, Texas            start buying big computers again."
  108. biff@biff.gbdata.com      -- John Akers, CEO of IBM
  109. NeXTMail and MIME OK     
  110.