前一个问题是你设置有问题,
关于线称,例子:
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 Form1v.ServerSocketGetThread(Sender : TObject;
ClientSocket : TServerClientWinSocket;
var SocketThread : TServerClientThread);
var
ServerThread : TServerThread;
begin
ServerThread := TServerThread.Create(true, ClientSocket);
SocketThread := ServerThread;
ServerThread.Resume;
end;