关于ClientSocket的古怪问题!!!高手请进~~~~~
我的代码如下:
int port;
AnsiString ip;
ip="10.10.10.10";
port=2250;
ClientSocket1->Address = ip;
ClientSocket1->Port = port;
ClientSocket1->Active = true;
if(ClientSocket1->Socket->Connected )
{
StatusBar1->Panels->Items[0]->Width = 200;
StatusBar1->Panels->Items[0]->Text = "连接 "+ip+" 成功!";
//发送联系报文
BYTE SendBuf[36];
BYTE Recv[300];
SendBuf[0]=1;
。。。。
SendBuf[35] = 0x10;
ClientSocket1->Socket->SendBuf(SendBuf,36);
//检验回送报文
if(ClientSocket1->Socket->ReceiveBuf(Recv,300)>1)
{
if(Recv[0] == 0x02 && Recv[3] == 0x01)
{
StatusBar1->Panels->Items[1]->Text = "接收联系报文成功";
WriteEdit("接收联系报文成功",0);
ClientSocket1->Active = false;
return true;
}
}
问题是,对方接收的报文总是在变的,而我接收到的报文也是在变。应该是不变的。
这个是为什么呢?ClientSocket1设置为阻塞状态。哪位高手指教一下呀~~~~