帮忙看看这个线程有什么问题?读服务端内容!
TMOThread = class(TThread)
private
ls_fillStr :string;
protected
Procedure FillEdit;
procedure Execute; override;
end;
procedure TMOThread.FillEdit;
begin
form1.MemoMo.Lines.Add(ls_fillStr);
end;
procedure TMOThread.Execute;
var
theStream :TWinSocketStream;
head:VAPP_Head;
bindresp:VAPP_Bind_Resp;
deliver:VApp_Deliver;
begin
while form1.ClientMo.Active do
try
TheStream :=TWinSocketStream.Create(form1.ClientMo.Socket,5000);
try
begin
fillchar(head,sizeof(VAPP_Head),0);
thestream.Readbuffer(head,sizeof(VAPP_Head));
head.len:=ntohl(head.len);
head.CommandId:=ntohl(head.CommandId);
head.seqno:=ntohl(head.seqno);
ls_fillStr:=inttostr(head.len);
synchronize(FillEdit);
ls_fillStr:=inttostr(head.CommandId);
synchronize(FillEdit);
ls_fillStr:=inttostr(head.seqno);
synchronize(FillEdit);
case head.CommandId of
APP_BIND_RESP:
begin
fillchar(bindresp,sizeof(VAPP_Bind_Resp),0);
thestream.Read(bindresp,sizeof(VAPP_Bind_Resp));
ls_fillStr:='接收到bindresp!';
synchronize(FillEdit);
ls_fillStr:=inttostr(bindresp.status);
synchronize(FillEdit);
begin
if bindresp.status=0 then
begin
ls_fillStr:='bindresp返回正常!';
molasttime:=now();
synchronize(FillEdit);
end
else
begin
ls_fillStr:='bindresp返回错误!';
synchronize(FillEdit);
end;
end;
end;
APP_UNBIND_RESP:
begin
ls_fillStr:='unbind_resp成功!';
synchronize(FillEdit);
end;
APP_ACTIVE_RESP:
begin
ls_fillStr:='active_resp成功!';
synchronize(FillEdit);
end;
else
begin
ls_fillStr:='收到其它包,命令: ' + inttostr(head.CommandId);
synchronize(FillEdit);
end;
end;
end;
finally
end;
finally
theStream.Free;
end;
end;
**********************
运行后在clientsocketconnect事件中tmothread.create(false);
问题是读取一个下发信息之后,其它的回复信息没有不知道是什么原因!
客户端是阻塞连接,服务端是线程服务器!