为什么我的ServerSocketClientDisconnect没有响应???(200分)

  • 主题发起人 主题发起人 rackrain
  • 开始时间 开始时间
R

rackrain

Unregistered / Unconfirmed
GUEST, unregistred user!
现用一个serversocket编写一个服务器端程序,采用stThreadBlocking方式,客户端断开后,为什么ServerSocketClientDisconnect事件没有响应??
procedure TForm1.ServerSocketGetThread(Sender: TObject;
ClientSocket: TServerClientWinSocket;
var SocketThread: TServerClientThread);
begin
if clientsocket.Connected then
socketthread:=TServerClientThread.Create(clientsocket);
end;

线程定义如下:
constructor TServerClientThread.Create(const client:TServerClientWinSocket);
begin
FreeOnTerminate:= True;
client_bank:=client;//客户端传入的数据包
inherited Create(False);
end;

procedure TServerClientThread.Execute;
var Stream : TWinSocketStream;
buffer1: array[0 .. 1023] of Char;
begin
Stream := TWinSocketStream.Create(client_bank, 30000);
FillChar(Buffer1,69, 0);
if Stream.WaitForData(2000) then //等待数据到来
begin
if Stream.Read(Buffer1, 69) = 0 then //读数据
client_bank.Close
else
begin
form1.snedit1.text:=buffer1;//处理受到的数据
clientsend:=buffer1;
case strtoint(copy(clientsend,3,3)) of
110:QuerySend;
end;
form1.edit1.text:=sendstr;
client_bank.SendText(sendstr);
Stream.Free;
client_bank.Close;
end;
end
else
client_bank.Close;
end;
 
后退
顶部