Hi everyone,
Could someone please help me with byte ordering regarding floating point variables? Actually the code is working correctly on Solaris, but not on Windows Xp. Here is a piece example of my code: ....
int x_snd=1;
float y_snd=1.13;
struct {
int xx_snd;
float yy_snd;
} data_snd;
int x_rec;
float y_rec;
struct {
int xx_rec;
float yy_rec;
} data_rec;
//marshalling
data_snd.xx_snd=htons(x_snd);
data_snd.yy_snd=htonl(*(int*) &y_snd);
//write data to socket
send(sock1, &data_snd, ...
//clean ...
//read data from socket
if recv(sock, &data_rec ...
//unmarshalling
x_rec=ntohs(data_rec.xx_rec);
y_rec= *(float*) &(ntohl(data_rec.yy_rec));
...
Th code was compiled with gcc on Unix and with MSVC++6 on wndows. Any of your help would be very appreciated and I would be glad if you could direct me to any link or document that gives usefull information about endianness ...
Thanking you in advance for your help, mk