[Vortex] Sending binary data

Jens Alfke jens at mooseyard.com
Thu Sep 6 18:56:28 CEST 2007


On 6 Sep '07, at 9:12 AM, Yourch, Chris wrote:

> I would suggest that the docs mention that the data is just binary
> bytes. Also, I would suggest that the function prototypes of the  
> methods
> that transmit the data are changed to "unsigned char *".

As I said before, "const void*" is the most appropriate parameter type  
for uninterpreted binary data. "unsigned char*" still implies a  
sequence of [single-byte] characters, just like "char*".

Moreover, declaring the parameter as "const void*" would eliminate the  
need for callers to cast the parameter when passing in pointers to  
other types.

> My confusion came from the fact that the data transmission functions
> accept the data as a "char *" which indicated to me that the data  
> was a
> string.

Actually you can tell from the fact that there is a following  
"message_size" parameter, that the message is not interpreted as a  
zero-terminated C string. But I agree that when I see the type  
"char*", I immediately think of C strings too.

And as long as we're nit-picking about parameter types, that  
"message_size" parameter should really be "size_t" (or at least  
"unsigned"), not "int", since negative values are meaningless. (I  
believe that same issue occurs in several other API calls.)

--Jens



More information about the Vortex mailing list