接受端可以用TWinSocketStream与TClientSocket结合起来使用。
如:声明
var
wssRecvStream : TWinSocketStream;
clientSocket1 : TClientSocket;
Buffer : Array[0..2047] of Char;
ecvNum : Integer;
begin
...
...
wssRecvStream := TWinSocketStream.Create(clientSocket1.Socket,receiveTimeOut);
...
if clientSocket1.Socket.Connected and wssRecvStream.WaitForData(receiveTimeOut) then
begin
FillChar(Buffer,SizeOf(Buffer),0);
recvNum := wssRecvStream.Read(Buffer, SizeOf(Buffer));
recevedBytes := recvNum;
end;
end;