I am using TCP/IP socket programming. I have a floating point value stored in a variable ret_val in my server cod
Use a textual representation ?
char buf[32] ;
snprintf(buf,sizeof buf,"%f",ret_val);
write(fd,buf,strlen(buf));
You can read that string and parse it back again with sscanf. (Maybe even make it line terminated - "%f\n" - so you'll know when the number ends.)
The direct approach is to simply
write(fd,&ret_val,sizeof ret_val);
In both cases you should check the return value of write and take proper action if an error occurs, or write() wrote less bytes than you told it to.