P
polmza13
Unregistered / Unconfirmed
GUEST, unregistred user!
用服务器端线程接收客户信息
在 while (not Terminated) and self.ClientSocket.Connecteddo
断点调试
可以正确获得客户信息
可是程序走完之后就出错
unit Unitseverhread;
interface
uses
Classes,ScktComp,unitdata,SysUtils;
type
Tseverhread = class(TServerClientThread)
private
aStream : TWinSocketStream;
{ Private declarations }
protected
procedure ClientExecute;
override;
public
constructor Create(ACreateSuspend:boolean;ASocket:TServerClientWinSocket);
end;
implementation
uses
unitsever;
constructor Tseverhread.Create(ACreateSuspend: boolean;
ASocket: TServerClientWinSocket);
begin
inherited Create(ACreateSuspend,ASocket);
end;
procedure Tseverhread.ClientExecute;
var
PacketPacket;//数据传送包
RegPacketRegPacket;//定义上线包
begin
aStream := TWinSocketStream.Create(self.ClientSocket, 1000);
while (not Terminated) and self.ClientSocket.Connecteddo
begin
if astream.WaitForData(1000) then
begin
new(packet);
new(RegPacket);
fillchar(Packet.Data,1024,#0);
Astream.ReadBuffer(Packet^,sizeof(TPacket));
if Packet^.FType='0' then
begin
fillchar(RegPacket^.name,21,#0);
move(Packet^.Data,RegPacket^,sizeof(TRegPacket));
frmsever.MemoSever.Lines.Add(RegPacket.name+'上线了');
dispose(RegPacket);
dispose(Packet);
end;
end;
sleep(100);
end;
end;
end.
在 while (not Terminated) and self.ClientSocket.Connecteddo
断点调试
可以正确获得客户信息
可是程序走完之后就出错
unit Unitseverhread;
interface
uses
Classes,ScktComp,unitdata,SysUtils;
type
Tseverhread = class(TServerClientThread)
private
aStream : TWinSocketStream;
{ Private declarations }
protected
procedure ClientExecute;
override;
public
constructor Create(ACreateSuspend:boolean;ASocket:TServerClientWinSocket);
end;
implementation
uses
unitsever;
constructor Tseverhread.Create(ACreateSuspend: boolean;
ASocket: TServerClientWinSocket);
begin
inherited Create(ACreateSuspend,ASocket);
end;
procedure Tseverhread.ClientExecute;
var
PacketPacket;//数据传送包
RegPacketRegPacket;//定义上线包
begin
aStream := TWinSocketStream.Create(self.ClientSocket, 1000);
while (not Terminated) and self.ClientSocket.Connecteddo
begin
if astream.WaitForData(1000) then
begin
new(packet);
new(RegPacket);
fillchar(Packet.Data,1024,#0);
Astream.ReadBuffer(Packet^,sizeof(TPacket));
if Packet^.FType='0' then
begin
fillchar(RegPacket^.name,21,#0);
move(Packet^.Data,RegPacket^,sizeof(TRegPacket));
frmsever.MemoSever.Lines.Add(RegPacket.name+'上线了');
dispose(RegPacket);
dispose(Packet);
end;
end;
sleep(100);
end;
end;
end.