parsing problem

Discussion in 'C' started by answerme, Jun 28, 2010.

  1. answerme

    answerme New Member

    Joined:
    Dec 17, 2007
    Messages:
    114
    Likes Received:
    0
    Trophy Points:
    0
    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:
    Code:
    [B]Server Side[/B]
    char buff[10];
    int my_byte=129;
    buff[0]=(my_byte & 0xff)>>8;
    buff[1]=(my_byte & 0xff);
    send(sock, buffstrlen(buff), 0);
    
    [B]Client Side[/B]
    char recv_data[10];   	
    recv(connected,recv_data,sizeof(recv_data),0);   
    my_byte=(recv_data[0]& 0xff)|(recv_data[1] & 0xff)>>8;
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Code:
    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.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice