S
sandra_phh
Unregistered / Unconfirmed
GUEST, unregistred user!
我用clientsocket 接收数据时报错,serversocket端发送文件流。
procedure TForm1.ClientSocket2Read(Sender: TObject;
Socket: TCustomWinSocket);
var
mystream: TMemoryStream ;
mybuf: array[0..1000] of byte;
myreclength : integer;
begin
try
mystream := TMemoryStream.Create ;
myreclength := ClientSocket2.Socket.ReceiveLength ;
ClientSocket2.Socket.ReceiveBuf(mybuf,myreclength);//到这行报错
mystream.Write(mybuf,myreclength);
if mystream.Size >= size then
begin
SaveDialog1.Filter := ExtractFileExt(fname) ;
if SaveDialog1.Execute then
begin
mystream.SaveToFile(SaveDialog1.FileName);
end;
end;
finally
mystream.Free ;
end;
end;
还有,我单步调试时发现收到的数据比文件流的数据少,请问serversocket会不会自
动分包发送呢?文件较大时应该怎样做呢?
procedure TForm1.ClientSocket2Read(Sender: TObject;
Socket: TCustomWinSocket);
var
mystream: TMemoryStream ;
mybuf: array[0..1000] of byte;
myreclength : integer;
begin
try
mystream := TMemoryStream.Create ;
myreclength := ClientSocket2.Socket.ReceiveLength ;
ClientSocket2.Socket.ReceiveBuf(mybuf,myreclength);//到这行报错
mystream.Write(mybuf,myreclength);
if mystream.Size >= size then
begin
SaveDialog1.Filter := ExtractFileExt(fname) ;
if SaveDialog1.Execute then
begin
mystream.SaveToFile(SaveDialog1.FileName);
end;
end;
finally
mystream.Free ;
end;
end;
还有,我单步调试时发现收到的数据比文件流的数据少,请问serversocket会不会自
动分包发送呢?文件较大时应该怎样做呢?