L
lixiaohui
Unregistered / Unconfirmed
GUEST, unregistred user!
stream1:=TWinSocketStream.Create(ClientSocket1.Socket,30000); //创建数据流
memo1.Lines.Add('-------------------向服务端发送BIND请求--------------------');
if not ClientSocket1.Active then
begin
memo1.Lines.Add('客户端没有打开');
exit;
end;
DateTimeToString(FV_Date1_S,'mmddhhnnss',now);
DateTimeToString(FV_Date2_S,'zzz',now);
FillChar(sBind,sizeof(sBind),0); //消息体
FillChar(sHead,sizeof(sHead),0); //消息头
str_i:=sizeof(sHead)+sizeof(sBind);
sBind.LonginType:=1;
strpcopy(sBind.LonginPass,FV_LoginPass);
strpcopy(sBind.LonginName,FV_LoginName);
abc:=htonl(FV_SNumber);
sHead.MessageLength:=htonl(str_i);
sHead.CommandId:=htonl(SGIP_Bind);
sHead.SNumber1:=abc;
sHead.SNumber2:=htonl(StrToInt(FV_Date1_S));
sHead.SNumber3:=htonl(StrToInt(FV_Date2_S));
stream1.WriteBuffer(sHead,sizeof(sHead));
stream1.WriteBuffer(sBind,sizeof(sBind));//这一行时提示“指定的网络名不再可用”
memo1.Lines.Add('sHead.MessageLength '+inttostr(ntohl(sHead.MessageLength)));
memo1.Lines.Add('sHead.CommandId '+inttostr(ntohl(sHead.CommandId)));
bc:=ntohl(abc);
memo1.Lines.Add('sHead.SNumber1 '+inttostr(bc));
memo1.Lines.Add('sHead.SNumber2 '+inttostr(ntohl(sHead.SNumber2)));
memo1.Lines.Add('sHead.SNumber3 '+inttostr(ntohl(sHead.SNumber3)));
memo1.Lines.Add('sBind.LonginType '+inttostr(sBind.LonginType));
memo1.Lines.Add('sBind.LonginName '+sBind.LonginName);
memo1.Lines.Add('sBind.LonginPass '+sBind.LonginPass);
memo1.Lines.Add('------------------Bind请求已发送----------------------');
if stream1.WaitForData(5000) then
begin
fillchar(cHead,sizeof(cHead),0);
fillchar(cbind_resp,sizeof(cBind_Resp),0);
stream1.ReadBuffer(cHead,sizeof(cHead));
stream1.ReadBuffer(cBind_resp,sizeof(cBind_resp));
end;
memo1.Lines.Add('cHead.MessageLength '+inttostr(ntohl(cHead.MessageLength)));
bc:=ntohl(cHead.CommandId);
memo1.Lines.Add('cHead.CommandId '+inttostr(bc));
bc:=ntohl(cHead.SNumber1);
memo1.Lines.Add('cHead.SNumber1 '+inttostr(bc));
memo1.Lines.Add('cHead.SNumber2 '+inttostr(ntohl(cHead.SNumber2)));
memo1.Lines.Add('cHead.SNumber3 '+inttostr(ntohl(cHead.SNumber3)));
memo1.Lines.Add('cBind.LonginType '+inttostr(cBind_resp.Result));
stream1.Free;
memo1.Lines.Add('-------------------向服务端发送BIND请求--------------------');
if not ClientSocket1.Active then
begin
memo1.Lines.Add('客户端没有打开');
exit;
end;
DateTimeToString(FV_Date1_S,'mmddhhnnss',now);
DateTimeToString(FV_Date2_S,'zzz',now);
FillChar(sBind,sizeof(sBind),0); //消息体
FillChar(sHead,sizeof(sHead),0); //消息头
str_i:=sizeof(sHead)+sizeof(sBind);
sBind.LonginType:=1;
strpcopy(sBind.LonginPass,FV_LoginPass);
strpcopy(sBind.LonginName,FV_LoginName);
abc:=htonl(FV_SNumber);
sHead.MessageLength:=htonl(str_i);
sHead.CommandId:=htonl(SGIP_Bind);
sHead.SNumber1:=abc;
sHead.SNumber2:=htonl(StrToInt(FV_Date1_S));
sHead.SNumber3:=htonl(StrToInt(FV_Date2_S));
stream1.WriteBuffer(sHead,sizeof(sHead));
stream1.WriteBuffer(sBind,sizeof(sBind));//这一行时提示“指定的网络名不再可用”
memo1.Lines.Add('sHead.MessageLength '+inttostr(ntohl(sHead.MessageLength)));
memo1.Lines.Add('sHead.CommandId '+inttostr(ntohl(sHead.CommandId)));
bc:=ntohl(abc);
memo1.Lines.Add('sHead.SNumber1 '+inttostr(bc));
memo1.Lines.Add('sHead.SNumber2 '+inttostr(ntohl(sHead.SNumber2)));
memo1.Lines.Add('sHead.SNumber3 '+inttostr(ntohl(sHead.SNumber3)));
memo1.Lines.Add('sBind.LonginType '+inttostr(sBind.LonginType));
memo1.Lines.Add('sBind.LonginName '+sBind.LonginName);
memo1.Lines.Add('sBind.LonginPass '+sBind.LonginPass);
memo1.Lines.Add('------------------Bind请求已发送----------------------');
if stream1.WaitForData(5000) then
begin
fillchar(cHead,sizeof(cHead),0);
fillchar(cbind_resp,sizeof(cBind_Resp),0);
stream1.ReadBuffer(cHead,sizeof(cHead));
stream1.ReadBuffer(cBind_resp,sizeof(cBind_resp));
end;
memo1.Lines.Add('cHead.MessageLength '+inttostr(ntohl(cHead.MessageLength)));
bc:=ntohl(cHead.CommandId);
memo1.Lines.Add('cHead.CommandId '+inttostr(bc));
bc:=ntohl(cHead.SNumber1);
memo1.Lines.Add('cHead.SNumber1 '+inttostr(bc));
memo1.Lines.Add('cHead.SNumber2 '+inttostr(ntohl(cHead.SNumber2)));
memo1.Lines.Add('cHead.SNumber3 '+inttostr(ntohl(cHead.SNumber3)));
memo1.Lines.Add('cBind.LonginType '+inttostr(cBind_resp.Result));
stream1.Free;