Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   parsing problem (http://www.go4expert.com/forums/parsing-problem-t22573/)

answerme 28Jun2010 15:49

parsing problem
Iam facing parsing problem .I have 2 bytes of data my_message. & i want to send this data to client (socket proging).Server side my parsing is ok ,but on client side its getting wrong
Code below:

Server Side
char buff[10];
int my_byte=129;
buff[0]=(my_byte & 0xff)>>8;
buff[1]=(my_byte & 0xff);
send(sock, buffstrlen(buff), 0);

Client Side
char recv_data[10];         
my_byte=(recv_data[0]& 0xff)|(recv_data[1] & 0xff)>>8;

xpi0t0s 29Jun2010 12:49

Re: parsing problem

buff[0]=(my_byte & 0xff)>>8;
OK, so what value do you think XY will have if you zero out X then shift it right by 8 bits (thus obliterating Y)?

> Server side my parsing is ok

And that's why you can't find the problem. NEVER assume the problem "isn't" in a particular location. You have to get that information from analysis of the root cause AFTER you have found it.

All times are GMT +5.5. The time now is 07:02.