5
520zhuhaibo
Unregistered / Unconfirmed
GUEST, unregistred user!
发现网络有丢包时采取下面的方式组包
按道理send一次,只需ReceiveBuf一次便可
wError := 0;
while wSize < MyHead^.RecordNum * 7 do
begin
RecordCount := Socket.ReceiveLength;
if RecordCount > 0 then
begin
RecordCount := socket.ReceiveBuf(ReciveBuf, RecordCount);
//Recv(Socket.SocketHandle, ReciveBuf, 65235, 0);
Move(ReciveBuf[0], BufInfo[wSize], RecordCount);
wSize := wSize + RecordCount;
end;
if wSize >= MyHead^.RecordNum * 7 then
Break;
Inc(wError);
if wError > 3 then
exit;
Sleep(100);
end;
现能组包,但是又出现了,端口没有断开,但是一段时间后会收不道数据,为何?
按道理send一次,只需ReceiveBuf一次便可
wError := 0;
while wSize < MyHead^.RecordNum * 7 do
begin
RecordCount := Socket.ReceiveLength;
if RecordCount > 0 then
begin
RecordCount := socket.ReceiveBuf(ReciveBuf, RecordCount);
//Recv(Socket.SocketHandle, ReciveBuf, 65235, 0);
Move(ReciveBuf[0], BufInfo[wSize], RecordCount);
wSize := wSize + RecordCount;
end;
if wSize >= MyHead^.RecordNum * 7 then
Break;
Inc(wError);
if wError > 3 then
exit;
Sleep(100);
end;
现能组包,但是又出现了,端口没有断开,但是一段时间后会收不道数据,为何?