kabilius
February 17th, 2009, 03:40 PM
Hi all,
I don't know how I solve the problem, but the problem magically disappeared.... :/
///////////////////////////////////////////
Hi all,
I am using C/C++ to construct and transmit packet to a server, and I am having trouble sending the correct byte if the value is greater than decimal 127.
Let's say this is the layout of my packet:
typedef struct
{
BYTE bHeader ;
BYTE bText1 ;
char szText2[ 5 ] ;
char szText3[ 2 ] ;
BYTE bText4 ;
unsigned char cText5 ;
} ClientToServer ;
cText5 may occasionally contain an unsigned value, so I use "unsigned char" as its data type.
When I run through my code in debug mode, I see cText5 is equal to 204, then I send the whole packet with the send() API:
send( sock, ( char* )&ClientToServer , sizeof( ClientToServer ), 0 ) ;
However, when I perform a packet capture, it shows that the last byte I sent, which is cText5, is equal to 1
Does anyone have an idea what I did wrong?
Thank you,
kab
I don't know how I solve the problem, but the problem magically disappeared.... :/
///////////////////////////////////////////
Hi all,
I am using C/C++ to construct and transmit packet to a server, and I am having trouble sending the correct byte if the value is greater than decimal 127.
Let's say this is the layout of my packet:
typedef struct
{
BYTE bHeader ;
BYTE bText1 ;
char szText2[ 5 ] ;
char szText3[ 2 ] ;
BYTE bText4 ;
unsigned char cText5 ;
} ClientToServer ;
cText5 may occasionally contain an unsigned value, so I use "unsigned char" as its data type.
When I run through my code in debug mode, I see cText5 is equal to 204, then I send the whole packet with the send() API:
send( sock, ( char* )&ClientToServer , sizeof( ClientToServer ), 0 ) ;
However, when I perform a packet capture, it shows that the last byte I sent, which is cText5, is equal to 1
Does anyone have an idea what I did wrong?
Thank you,
kab