unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ScktComp, ExtCtrls;
type
TForm1 = class(TForm)
ClientSocket1: TClientSocket;
Label1: TLabel;
Button1: TButton;
procedure ClientSocket1Read(Sender: TObject; Socket: TCustomWinSocket);
procedure Button1Click(Sender: TObject);
procedure ClientSocket1Connect(Sender: TObject;
Socket: TCustomWinSocket);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
FStream: TFileStream;
SizeOfFile: Integer;
pBuffer: Pointer;
AlreadyReceived: integer;
FileStream: TFileStream;
Buffer: array[0..4096] of Byte; // die Größe des Puffers ist beliebig, müsste nur (s.u.)
SizeOfBuffer: integer;
implementation
{$R *.dfm}
procedure TForm1.ClientSocket1Read(Sender: TObject;
Socket: TCustomWinSocket);
var
Buffer: array[0..4096] of Byte; // die Größe des Puffers ist beliebig, müsste nur (s.u.)
SizeOfBuffer: integer;
begin
pBuffer := @Buffer;
SizeOfBuffer := Socket.ReceiveBuf(pBuffer^, 4096); //hier angeglichen werden
FileStream.Write(pBuffer^, SizeOfBuffer);
Inc(AlreadyReceived, SizeOfBuffer);
Socket.SendText(IntToStr(AlreadyReceived));
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ClientSocket1.Active:=false;
filestream.Free;
end;
procedure TForm1.ClientSocket1Connect(Sender: TObject;
Socket: TCustomWinSocket);
begin
FileStream := TFileStream.Create('c:\temp\datei2.bmp', fmCreate or fmOpenWrite);
end;
end.