All pastes #131147 Raw Edit

Something

public text v1 · immutable
#131147 ·published 2006-08-14 10:59 UTC
rendered paste body
procedure tform1.cread(Sender: TObject; Socket: TCustomWinSocket);
var buf:array[0..4096] of char;
    fs:tmemorystream;
    s:String;
    i:integer;
begin
if not b then
begin
s:=socket.ReceiveText;
if s[1]='c' then memo1.lines.add('command: '+s);
if s[1]='d' then
begin
delete(s,1,1);
nsize:=strtoint(s);
memo1.lines.add('data size: '+inttostr(nsize));
b:=true;
fs:=tmemorystream.Create;
fs.SetSize(nsize);
end;end else
begin
i:=socket.ReceiveBuf(buf, sizeof(buf));
inc(cnt, i);
fs.WriteBuffer(buf, i);
memo1.lines.add(inttostr(cnt));
if cnt>=nsize then
begin
memo1.lines.add('data read!');
fs.SaveToFile(fname);
b:=false;
end;
end;
end;