//@@@TServerThread.ClientExecute;
//@@@当SendThread执行Execute时,这里相应的执行ClientExecute
procedure TServerThread.ClientExecute;
var
Buffer : array[0..299] of Char;
Number : Integer;
begin
while (not Terminated) and (Socket.Connected)do
begin
try
if SocketStream.WaitForData(2000) then
begin
FillChar(Buffer, SizeOf(Buffer), 0);
Number := SocketStream.Read(Buffer, SizeOf(Buffer));
if Number < SizeOf(Buffer) then
begin
Stream.Write(Buffer, Number);
Synchronize(CallOnCommandReceive);
end
else
begin
Stream.Write(Buffer, Number);
end;
end;
except //当连接断开时可能有except
Socket.Close;
Terminate;
//HandleException;
end;
end;
end;
//ServerSocket的OnGetThread事件代码
procedure TMainForm.JavaApplet_ServerSocketGetThread(Sender : TObject;
ClientSocket : TServerClientWinSocket;
var SocketThread : TServerClientThread);
var
ServerThread : TServerThread;
begin
ServerThread := TServerThread.Create(true, ClientSocket);
ServerThread.OnCommandReceive := JavaApplet_OnCommandReceive;
SocketThread := ServerThread;
ServerThread.Resume;
end;
摘自我的程序,调试通过