I am using TCP/IP socket programming. I have a floating point value stored in a variable ret_val in my server cod
float f = ...;
size_t float_size = sizeof(float);
const char* buffer = (const char *) &f;
send(mySocket, buffer, float_size, 0);
This code will work fine if both the server and client use the same platform. If the platforms are different, you will have to negotiate message sizes and endianess explicitly.