K
Kent
Unregistered / Unconfirmed
GUEST, unregistred user!
客户端:
procedure TForm1.BitBtn3Click(Sender: TObject);
var
Stream:TMemoryStream;
Stream_size:integer;
begin
Stream:=TMemoryStream.Create;
for i:=1 to 100 do
begin
Sendstrings.pz_id:=i;
Sendstrings.jc_ip:=i;
Sendstrings.pz_cs:=i;
Sendstrings.jc_dns:='0123456789012345678901234567890123456789';
Stream.Write(Sendstrings.pz_id,4);
Stream.Write(Sendstrings.jc_ip,4);
Stream.Write(Sendstrings.jc_dns,40);
Stream.Write(Sendstrings.pz_cs,4);
end;
Stream.Position:=0;
ClientSocket1.Socket.SendStream(Stream);
end;
服务器端:
procedure TForm1.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
var
Stream:TMemoryStream;
Receivestrings:struct_rec;
begin
while Socket.ReceiveLength>0 do
begin
memo1.Lines.Add(Receivestrings.jc_dns);
Socket.Receivebuf(Receivestrings.pz_id,4);
Socket.Receivebuf(Receivestrings.jc_ip,4);
Socket.Receivebuf(Receivestrings.jc_dns,40);
Socket.Receivebuf(Receivestrings.pz_cs,4);
end;
end;
现在发现socket数据缓冲为4096Bytes,当客户端发送数据大于4096时,如果一个记录
长度为64(正好是4096的因子),则接受正常...
而现在记录长度为52,所以发送到第78条时,剩下了一小段,52*78=4056<4096,再接受第
79条时,数据接受的就不对了,请问如何处理这种大数据量的传送....
procedure TForm1.BitBtn3Click(Sender: TObject);
var
Stream:TMemoryStream;
Stream_size:integer;
begin
Stream:=TMemoryStream.Create;
for i:=1 to 100 do
begin
Sendstrings.pz_id:=i;
Sendstrings.jc_ip:=i;
Sendstrings.pz_cs:=i;
Sendstrings.jc_dns:='0123456789012345678901234567890123456789';
Stream.Write(Sendstrings.pz_id,4);
Stream.Write(Sendstrings.jc_ip,4);
Stream.Write(Sendstrings.jc_dns,40);
Stream.Write(Sendstrings.pz_cs,4);
end;
Stream.Position:=0;
ClientSocket1.Socket.SendStream(Stream);
end;
服务器端:
procedure TForm1.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
var
Stream:TMemoryStream;
Receivestrings:struct_rec;
begin
while Socket.ReceiveLength>0 do
begin
memo1.Lines.Add(Receivestrings.jc_dns);
Socket.Receivebuf(Receivestrings.pz_id,4);
Socket.Receivebuf(Receivestrings.jc_ip,4);
Socket.Receivebuf(Receivestrings.jc_dns,40);
Socket.Receivebuf(Receivestrings.pz_cs,4);
end;
end;
现在发现socket数据缓冲为4096Bytes,当客户端发送数据大于4096时,如果一个记录
长度为64(正好是4096的因子),则接受正常...
而现在记录长度为52,所以发送到第78条时,剩下了一小段,52*78=4056<4096,再接受第
79条时,数据接受的就不对了,请问如何处理这种大数据量的传送....