Z
zhouhuilun
Unregistered / Unconfirmed
GUEST, unregistred user!
客户端clientsocket如何去接收serversocket端的主动发过来的信息,我用clientsocket的onread去接收,但是没有反应,请高手赐教,万分感谢!!!
下面是onread部分的源代码:
procedure TCMPPTest.CMPPClientSocket1Read(Sender: TObject;
Socket: TCustomWinSocket);
var
CommandID:longword;
Recv1,Recv2:integer;
begin
fillchar(RHead,sizeof(RHead),0);
Recv1:=socket.ReceiveBuf(RHead,Sizeof(RHead));
CommandID:=ntohl(RHead.Command_ID);
if CommandID=CMPP_TERMINATE_RESP then
begin
memo2.Lines.Add('********接收到断开请求*******');
fillchar(SHead,sizeof(SHead),0);
SHead.Total_length:=htonl(sizeof(SHead));
SHead.Command_ID:=htonl(CMPP_TERMINATE_RESP);
SHead.Sequence_ID:=RHead.Sequence_ID;
socket.SendBuf(SHead,sizeof(SHead));
end;
end;
是不是于clientsocket的clienttype
下面是onread部分的源代码:
procedure TCMPPTest.CMPPClientSocket1Read(Sender: TObject;
Socket: TCustomWinSocket);
var
CommandID:longword;
Recv1,Recv2:integer;
begin
fillchar(RHead,sizeof(RHead),0);
Recv1:=socket.ReceiveBuf(RHead,Sizeof(RHead));
CommandID:=ntohl(RHead.Command_ID);
if CommandID=CMPP_TERMINATE_RESP then
begin
memo2.Lines.Add('********接收到断开请求*******');
fillchar(SHead,sizeof(SHead),0);
SHead.Total_length:=htonl(sizeof(SHead));
SHead.Command_ID:=htonl(CMPP_TERMINATE_RESP);
SHead.Sequence_ID:=RHead.Sequence_ID;
socket.SendBuf(SHead,sizeof(SHead));
end;
end;
是不是于clientsocket的clienttype