关于发送封包问题.麻烦帮忙看下
typedef struct _SEND
{
BYTE BuffTop[2]; //固定包头 0xAA,0xBB;
BYTE*BuffText; //数据内容
}SEND,PSEND;
union Buff
{
struct _SEND _Send;
BYTE SendBytes[];
};
比如我要发送一个 0x88,0x77,0x66,0x55,0x44的包出去.
union Buff Send;
Send._Send.BuffTop[1] = 0xAA;
Send._Send.BuffTop[2] = 0xBB;
BYTE BuffTxt[5] = {0x88,0x77,0x66,0x55,0x44};
Send._Send.BuffText = BuffTxt;
DWORD Buffs = (DWORD)Send.SendBytes;
ClientSocket-> Socket-> SendText(IntToStr(Buffs));
为什么发出去的包内容会是
0x88,0x77,0x66,0x55,0x44 而不是0xAA,0xBB,0x88,0x77,0x66,0x55,0x44呢?
如果我要写个类似这样的程序要怎么定义结构?
[解决办法]
直接用BYPE 数组存储要发送的内容send即可