定义一个MsgLength的变量来标识接受到的数据,然后修改这个变量来处理接收缓冲区。如果把这个变量设为0就相当于清空了你的接收Buffer了。
var msgLength:Integer;
msgBuffer:array[0..2039]of Byte;
begin
......
try
msgLength:=FormMain.myClient.Socket.Recv(msgBuffer,SizeOf(msgBuffer));
//msgLength就是此次收到的实际信息长度
if msgLength<1 then
FormMain.myClient.ReadBuffer(msgBuffer,3)
else
{do something you want}
except
;
end;
......
end;