1,593
社区成员
发帖
与我相关
我的任务
分享
function receSocket(socket:TCustomWinSocket)
var
i,L:Integer;
buff:Array of Byte;
begin
L:= Socket.ReceiveLength;
if L<=0 then
exit;
SetLength(buff, L);
i:= Socket.ReceiveBuf(buff[0], L);
if i<L then
receSocket(Socket);
end;
这里有几个问题:接收时应该创建一个缓冲区,接收时PUSH,处理时POP。使用环形缓冲区。
不要在接收的时候同时显示到界面,除非你的用户量和接收速度都很少。
TCP连接要处理粘包的问题。