Procedure TMyServerThread.clientExecute;
var stream:TWinSocketStream;
Buffer:arrar[0..9]of char;
Begin
{一直循环,到线程终止或连接断开}
While (not Terminated) and ClientSocket.Connected do
Begin
Try Stream:=TwinSocketStream.Create(ClientSOcket,60000);
try
{填充Buffer数组}
FillChar(Buffer,10,0);
{给客户60秒的时间}
If Stream.WaitForData(60000) then
Begin
{在这里取数和给客户返回信息}
......
End
Else ClientSocket.Close;
Finally
Stream.Free;
End;
Except
HandleException;
End;
End;
End;
delphi 里有个例子