unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ScktComp;
type
TDLFile=
array[0..2048-1]
of Byte;
TForm1 =
class(TForm)
Button1: TButton;
ServerSocket1: TServerSocket;
ClientSocket1: TClientSocket;
procedure Button1Click(Sender: TObject);
procedure ClientSocket1Read(Sender: TObject; Socket: TCustomWinSocket);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
dlCounter: Cardinal = 0;
implementation
{$R *.dfm}
procedure WriteToNewFile(bByteDat: TDLFile; iSize: Integer);
var
hDat:
File;
begin
if FileExists('
C:\new_bild.bmp')
then
begin
AssignFile(hDat, '
C:\new_bild.bmp');
ReSet(hDat, 1);
Seek(hDat, soFromBeginning+dlCounter);
BlockWrite(hDat, bByteDat, iSize);
inc(dlCounter, iSize);
CloseFile(hDat);
end
else begin
AssignFile(hDat, '
C:\new_bild.bmp');
ReWrite(hDat, 1);
BlockWrite(hDat, bByteDat, iSize);
dlCounter := iSize;
CloseFile(hDat);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
type TDLFile=
array[0..2048-1]
of Byte;
var datei:
file;
buffer: TDLFile;
iResult: Integer;
begin
AssignFile(datei, '
D:\Balls\balls\Cedfence.bmp');
ReSet(datei, 1);
while iResult <> 0
do
while not eof(datei) = true
do
begin
BlockRead(datei, buffer, 2048, iResult);
ServerSocket1.Socket.Connections[0].SendBuf(buffer, iResult);
end;
CloseFile(datei);
end;
procedure TForm1.ClientSocket1Read(Sender: TObject;
Socket: TCustomWinSocket);
var
buffer: TDLFile;
iResult: Integer;
//Was soll das hier eigentlich??
begin
ClientSocket1.Socket.ReceiveBuf(buffer, Socket.ReceiveLength);
WriteToNewFile(buffer, ClientSocket1.Socket.ReceiveLength);
end;
end.