Title: | DIGITAL UNIX (FORMERLY KNOWN AS DEC OSF/1) |
Notice: | Welcome to the Digital UNIX Conference |
Moderator: | SMURF::DENHAM |
Created: | Thu Mar 16 1995 |
Last Modified: | Fri Jun 06 1997 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 10068 |
Total number of notes: | 35879 |
A software developer who is porting his application to Digital UNIX v4.0 would like to know if there is a function or method to find out the size of data that he is transferring using XDR. Currently he is estimating the size using strlen and padding with a fixed amount, but he would like a more exact method to do this. Here are his questions: "I use XDR to transfer structure through the socket. My structure is very complicated and of variable length. Inside there are several linked list. The list can be 1,000 nodes or 1 node. Currently I allocate a big enough buffer to store the XDR string. This is very unefficient when the list has only a few values. Is there a strlen function for XDR so I can know the length of binary string." "Currently what I did is, I estimate how many bytes I need, for string I allocate (strlen + 20) but this is not sharp solution. What I need is a function like that int xdrlen(xdrstring, ... structure definition) I want to know if DEC has coded it. I have read the whole network programming manual, but found nothing."
T.R | Title | User | Personal Name | Date | Lines |
---|---|---|---|---|---|
8759.1 | A few XDR sizes | NETRIX::"werme@zk3.dec.com" | Ric Werme | Fri Feb 14 1997 17:06 | 20 |
I don't know of libc routines that let you estimate how long XDR data will be. It would be fairly easy to write a new XDR module that merely counts the length of data to be encoded, and using the public domain RPC code would provide enough hints. (That has a lot of 32/64 bit issues, so it doesn't replace our libc code.) Some sizes (I may not be exactly right): xdr_bytes, xdr_string: The number of bytes, rounded up to next multiple of 4, plus 4. xdr_char, xdr_short, xdr_int, xdr_long, xdr_float xdr_bool, xdr_enum: 4 bytes. xdr_longlong, xdr_hyper, xdr_double: 8 bytes Ah - here's an idea - try calling xdr_getpos before and after encoding something. The difference is the number of bytes used. Me? I'd just look at the messages sent via tcpdump and figure the length and structure. [Posted by WWW Notes gateway] | |||||
8759.2 | thanks | HYDRA::DORHAMER | Fri Feb 14 1997 19:30 | 3 | |
Thanks for your help. I'll relay the info to the customer. Karen |