int send_buf1[234]=
{
0x00,0xE8,0x00,0x00,0x01,0x00,0x00,0x00,0x18,0x63,
0x95,0x00,0x18,0x63,0x95,0x00,0xF0,0x06,0x00,0x00,
0x30,0x30,0x00,0x00,0x28,0x63,0x95,0x00,0x28,0x63,
0x95,0x00,0x10,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,
0x00,0x00,0x30,0x30,0x20,0x00,0x48,0x63,0x95,0x00,
0x48,0x63,0x95,0x00,0x10,0x00,0x00,0x20,0x46,0x30,
0x20,0x30,0x36,0x20,0x30,0x30,0x20,0x30,0x30,0x20,
0x33,0x30,0x20,0x33,0x30,0x20,0x30,0x30,0x38,0x20,
0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x31,0x20,0x30,
0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x36,0x33,0x20,
0x39,0x35,0x20,0x30,0x30,0x20,0x31,0x30,0x20,0x30,
0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x32,0x30,
0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,
0x31,0x33,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,
0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x30,
0x20,0x30,0x30,0x20,0x30,0x33,0x20,0x30,0x30,0x20,
0x30,0x30,0x20,0x30,0x30,0x20,0x33,0x30,0x20,0x33,
0x30,0x20,0x32,0x30,0x20,0x30,0x30,0x20,0x34,0x38,
0x20,0x36,0x33,0x20,0x39,0x35,0x20,0x30,0x30,0x20,
0x34,0x38,0x20,0x36,0x33,0x20,0x39,0x35,0x20,0x30,
0x30,0x20,0x31,0x30,0x20,0x30,0x30,0x20,0x30,0x30,
0x20,0x32,0x30,0x20,0x34,0x36,0x20,0x33,0x30,0x20,
0x32,0x30,0x20,0x00
};
Socket->SendBuf(send_buf1,234);
在IDE下调试,收到的数据包也和发出的不是完全一样的,特别是开始几个字节。
5 个解决方案
#1
应该不会的。
#2
是的,
这是服务端的程序,
大家可以自己写写
Byte *sock_buf_Byte =new Byte(sok_len);
Socket->ReceiveBuf(sock_buf_Byte,sok_len);
String sok_b_s="";
for(int i=0;i<sok_len;i++)
{
String hh_temp=IntToHex(sock_buf_Byte[i],2)+" ";
sok_b_s=sok_b_s+hh_temp.SubString(hh_temp.Length()-2,3);
}
Memo1->Lines->Add(sok_b_s);
delete sock_buf_Byte;
数据就是不一样,
这是服务端的程序,
大家可以自己写写
Byte *sock_buf_Byte =new Byte(sok_len);
Socket->ReceiveBuf(sock_buf_Byte,sok_len);
String sok_b_s="";
for(int i=0;i<sok_len;i++)
{
String hh_temp=IntToHex(sock_buf_Byte[i],2)+" ";
sok_b_s=sok_b_s+hh_temp.SubString(hh_temp.Length()-2,3);
}
Memo1->Lines->Add(sok_b_s);
delete sock_buf_Byte;
数据就是不一样,
#3
你看一下吧,是发送的时候长度计算有误,我已经试过这个没有问题.
void __fastcall TForm1::ServerSocket1ClientRead(TObject *Sender,
TCustomWinSocket *Socket)
{
const int sok_len(234);
int send_buf1[sok_len];
Socket->ReceiveBuf(send_buf1,sizeof(send_buf1));
String sok_b_s="";
for(int i=0;i<sok_len;i++)
{
String hh_temp=IntToHex(send_buf1[i],2)+" ";
sok_b_s=sok_b_s+hh_temp.SubString(hh_temp.Length()-2,3);
}
Memo1->Lines->Add(sok_b_s);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int send_buf1[234]=
{
0x00,0xE8,0x00,0x00,0x01,0x00,0x00,0x00,0x18,0x63,
0x95,0x00,0x18,0x63,0x95,0x00,0xF0,0x06,0x00,0x00,
0x30,0x30,0x00,0x00,0x28,0x63,0x95,0x00,0x28,0x63,
0x95,0x00,0x10,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,
0x00,0x00,0x30,0x30,0x20,0x00,0x48,0x63,0x95,0x00,
0x48,0x63,0x95,0x00,0x10,0x00,0x00,0x20,0x46,0x30,
0x20,0x30,0x36,0x20,0x30,0x30,0x20,0x30,0x30,0x20,
0x33,0x30,0x20,0x33,0x30,0x20,0x30,0x30,0x38,0x20,
0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x31,0x20,0x30,
0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x36,0x33,0x20,
0x39,0x35,0x20,0x30,0x30,0x20,0x31,0x30,0x20,0x30,
0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x32,0x30,
0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,
0x31,0x33,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,
0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x30,
0x20,0x30,0x30,0x20,0x30,0x33,0x20,0x30,0x30,0x20,
0x30,0x30,0x20,0x30,0x30,0x20,0x33,0x30,0x20,0x33,
0x30,0x20,0x32,0x30,0x20,0x30,0x30,0x20,0x34,0x38,
0x20,0x36,0x33,0x20,0x39,0x35,0x20,0x30,0x30,0x20,
0x34,0x38,0x20,0x36,0x33,0x20,0x39,0x35,0x20,0x30,
0x30,0x20,0x31,0x30,0x20,0x30,0x30,0x20,0x30,0x30,
0x20,0x32,0x30,0x20,0x34,0x36,0x20,0x33,0x30,0x20,
0x32,0x30,0x20,0x00
};
ClientSocket1->Socket->SendBuf(send_buf1,sizeof(send_buf1));
void __fastcall TForm1::ServerSocket1ClientRead(TObject *Sender,
TCustomWinSocket *Socket)
{
const int sok_len(234);
int send_buf1[sok_len];
Socket->ReceiveBuf(send_buf1,sizeof(send_buf1));
String sok_b_s="";
for(int i=0;i<sok_len;i++)
{
String hh_temp=IntToHex(send_buf1[i],2)+" ";
sok_b_s=sok_b_s+hh_temp.SubString(hh_temp.Length()-2,3);
}
Memo1->Lines->Add(sok_b_s);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int send_buf1[234]=
{
0x00,0xE8,0x00,0x00,0x01,0x00,0x00,0x00,0x18,0x63,
0x95,0x00,0x18,0x63,0x95,0x00,0xF0,0x06,0x00,0x00,
0x30,0x30,0x00,0x00,0x28,0x63,0x95,0x00,0x28,0x63,
0x95,0x00,0x10,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,
0x00,0x00,0x30,0x30,0x20,0x00,0x48,0x63,0x95,0x00,
0x48,0x63,0x95,0x00,0x10,0x00,0x00,0x20,0x46,0x30,
0x20,0x30,0x36,0x20,0x30,0x30,0x20,0x30,0x30,0x20,
0x33,0x30,0x20,0x33,0x30,0x20,0x30,0x30,0x38,0x20,
0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x31,0x20,0x30,
0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x36,0x33,0x20,
0x39,0x35,0x20,0x30,0x30,0x20,0x31,0x30,0x20,0x30,
0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x32,0x30,
0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,
0x31,0x33,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,
0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x30,
0x20,0x30,0x30,0x20,0x30,0x33,0x20,0x30,0x30,0x20,
0x30,0x30,0x20,0x30,0x30,0x20,0x33,0x30,0x20,0x33,
0x30,0x20,0x32,0x30,0x20,0x30,0x30,0x20,0x34,0x38,
0x20,0x36,0x33,0x20,0x39,0x35,0x20,0x30,0x30,0x20,
0x34,0x38,0x20,0x36,0x33,0x20,0x39,0x35,0x20,0x30,
0x30,0x20,0x31,0x30,0x20,0x30,0x30,0x20,0x30,0x30,
0x20,0x32,0x30,0x20,0x34,0x36,0x20,0x33,0x30,0x20,
0x32,0x30,0x20,0x00
};
ClientSocket1->Socket->SendBuf(send_buf1,sizeof(send_buf1));
#4
int类型占4个字节.
#5
支持!
#1
应该不会的。
#2
是的,
这是服务端的程序,
大家可以自己写写
Byte *sock_buf_Byte =new Byte(sok_len);
Socket->ReceiveBuf(sock_buf_Byte,sok_len);
String sok_b_s="";
for(int i=0;i<sok_len;i++)
{
String hh_temp=IntToHex(sock_buf_Byte[i],2)+" ";
sok_b_s=sok_b_s+hh_temp.SubString(hh_temp.Length()-2,3);
}
Memo1->Lines->Add(sok_b_s);
delete sock_buf_Byte;
数据就是不一样,
这是服务端的程序,
大家可以自己写写
Byte *sock_buf_Byte =new Byte(sok_len);
Socket->ReceiveBuf(sock_buf_Byte,sok_len);
String sok_b_s="";
for(int i=0;i<sok_len;i++)
{
String hh_temp=IntToHex(sock_buf_Byte[i],2)+" ";
sok_b_s=sok_b_s+hh_temp.SubString(hh_temp.Length()-2,3);
}
Memo1->Lines->Add(sok_b_s);
delete sock_buf_Byte;
数据就是不一样,
#3
你看一下吧,是发送的时候长度计算有误,我已经试过这个没有问题.
void __fastcall TForm1::ServerSocket1ClientRead(TObject *Sender,
TCustomWinSocket *Socket)
{
const int sok_len(234);
int send_buf1[sok_len];
Socket->ReceiveBuf(send_buf1,sizeof(send_buf1));
String sok_b_s="";
for(int i=0;i<sok_len;i++)
{
String hh_temp=IntToHex(send_buf1[i],2)+" ";
sok_b_s=sok_b_s+hh_temp.SubString(hh_temp.Length()-2,3);
}
Memo1->Lines->Add(sok_b_s);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int send_buf1[234]=
{
0x00,0xE8,0x00,0x00,0x01,0x00,0x00,0x00,0x18,0x63,
0x95,0x00,0x18,0x63,0x95,0x00,0xF0,0x06,0x00,0x00,
0x30,0x30,0x00,0x00,0x28,0x63,0x95,0x00,0x28,0x63,
0x95,0x00,0x10,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,
0x00,0x00,0x30,0x30,0x20,0x00,0x48,0x63,0x95,0x00,
0x48,0x63,0x95,0x00,0x10,0x00,0x00,0x20,0x46,0x30,
0x20,0x30,0x36,0x20,0x30,0x30,0x20,0x30,0x30,0x20,
0x33,0x30,0x20,0x33,0x30,0x20,0x30,0x30,0x38,0x20,
0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x31,0x20,0x30,
0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x36,0x33,0x20,
0x39,0x35,0x20,0x30,0x30,0x20,0x31,0x30,0x20,0x30,
0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x32,0x30,
0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,
0x31,0x33,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,
0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x30,
0x20,0x30,0x30,0x20,0x30,0x33,0x20,0x30,0x30,0x20,
0x30,0x30,0x20,0x30,0x30,0x20,0x33,0x30,0x20,0x33,
0x30,0x20,0x32,0x30,0x20,0x30,0x30,0x20,0x34,0x38,
0x20,0x36,0x33,0x20,0x39,0x35,0x20,0x30,0x30,0x20,
0x34,0x38,0x20,0x36,0x33,0x20,0x39,0x35,0x20,0x30,
0x30,0x20,0x31,0x30,0x20,0x30,0x30,0x20,0x30,0x30,
0x20,0x32,0x30,0x20,0x34,0x36,0x20,0x33,0x30,0x20,
0x32,0x30,0x20,0x00
};
ClientSocket1->Socket->SendBuf(send_buf1,sizeof(send_buf1));
void __fastcall TForm1::ServerSocket1ClientRead(TObject *Sender,
TCustomWinSocket *Socket)
{
const int sok_len(234);
int send_buf1[sok_len];
Socket->ReceiveBuf(send_buf1,sizeof(send_buf1));
String sok_b_s="";
for(int i=0;i<sok_len;i++)
{
String hh_temp=IntToHex(send_buf1[i],2)+" ";
sok_b_s=sok_b_s+hh_temp.SubString(hh_temp.Length()-2,3);
}
Memo1->Lines->Add(sok_b_s);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int send_buf1[234]=
{
0x00,0xE8,0x00,0x00,0x01,0x00,0x00,0x00,0x18,0x63,
0x95,0x00,0x18,0x63,0x95,0x00,0xF0,0x06,0x00,0x00,
0x30,0x30,0x00,0x00,0x28,0x63,0x95,0x00,0x28,0x63,
0x95,0x00,0x10,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,
0x00,0x00,0x30,0x30,0x20,0x00,0x48,0x63,0x95,0x00,
0x48,0x63,0x95,0x00,0x10,0x00,0x00,0x20,0x46,0x30,
0x20,0x30,0x36,0x20,0x30,0x30,0x20,0x30,0x30,0x20,
0x33,0x30,0x20,0x33,0x30,0x20,0x30,0x30,0x38,0x20,
0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x31,0x20,0x30,
0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x36,0x33,0x20,
0x39,0x35,0x20,0x30,0x30,0x20,0x31,0x30,0x20,0x30,
0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x32,0x30,
0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,
0x31,0x33,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,
0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x30,
0x20,0x30,0x30,0x20,0x30,0x33,0x20,0x30,0x30,0x20,
0x30,0x30,0x20,0x30,0x30,0x20,0x33,0x30,0x20,0x33,
0x30,0x20,0x32,0x30,0x20,0x30,0x30,0x20,0x34,0x38,
0x20,0x36,0x33,0x20,0x39,0x35,0x20,0x30,0x30,0x20,
0x34,0x38,0x20,0x36,0x33,0x20,0x39,0x35,0x20,0x30,
0x30,0x20,0x31,0x30,0x20,0x30,0x30,0x20,0x30,0x30,
0x20,0x32,0x30,0x20,0x34,0x36,0x20,0x33,0x30,0x20,
0x32,0x30,0x20,0x00
};
ClientSocket1->Socket->SendBuf(send_buf1,sizeof(send_buf1));
#4
int类型占4个字节.
#5
支持!