Code:
float my_value = 0.0;
//...
write(fd, &my_value, sizeof my_value);
//...
read(fd, &my_value, sizeof my_value);
That really isn't a good idea unless you know this will always happen on the same machine, so normally I convert numbers to text before sending them. There normally isn't much of a point sending values in their binary formats unless you're sending precisely-aligned data structures with exacting binary information; a category that floating points don't fall into. You won't lose much converting to and from a string with *
printf and
strto*. And unless you're sending strictly a single type and nothing else, you'll need some sort of alignment control (which is usually done with a simple text protocol) to prevent a minor error from corrupting all subsequent IPC.
ta0kira