[omniORB] Calculating the message size of a response
Floris Bruynooghe
floris.bruynooghe at gmail.com
Tue Jan 5 22:41:28 GMT 2010
On Tue, Jan 05, 2010 at 05:05:39PM +0000, Duncan Grisby wrote:
> On Mon, 2010-01-04 at 21:19 +0000, Floris Bruynooghe wrote:
> > Is it somehow possible to calculate the size of a message before
> > sending it on the server side? Basically perform the marshalling
> > (from within python) and check the result so you could decide to raise
> > a custom exception which is more specific. (Bonus points for then
> > being able to send this already marshalled data instead of having to
> > repeat that)
>
> Well, you can use the omniORB.cdrMarshal function to marshal the data
> into a string. There's no way to then send that as the reply, so you
> would end up doing the marshalling work twice, and you'd have to hold
> the whole marshalled data in memory rather than streaming it over the
> network.
>
> At a C++ level, there is a cdrCountingStream class that you can use to
> work out how big data will be without storing the marshalled form. That
> isn't currently exposed to Python code, but I suppose you could add
> something similar to the cdrMarshal function that did it. The other
> limitation is that you can't use it if you are using valuetypes, since
> the valuetype chunked encoding size is dependent on the buffering of the
> data.
Thanks for the quick and clear answer, I should be able to create
something useful out of this.
Regards
Floris
--
Debian GNU/Linux -- The Power of Freedom
www.debian.org | www.gnu.org | www.kernel.org
More information about the omniORB-list
mailing list