[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 344
  • Last Modified:

Virtual Private Network

I am writing a communication software and I want to be able to transfer data (probably text files) over a VPN. Any ideas or possible better solutions.
I am very generous with points, I'm looking for something that is more or less bug proof and secure. I have a total of 720pts avalible for this question depending on speed and value.
0
rpmcdonald
Asked:
rpmcdonald
  • 4
  • 2
1 Solution
 
rbohacCommented:
Have you tried a simple FTP server? Is it to slow?

You could also use the Indy (IDTCPClient/IDTCPServer) components to write a client and a server application.

Example:

procedure TForm1.Button1Click(Sender: TObject);
var
  FileStream : TFileStream;
begin
  {Client Side}
  FileStream := TFileStream.Create('c:\MyFile.txt',fmOpenRead);
  try
    IdTCPClient1.Host := 'Whatever';
    IdTCPClient1.Port := 12345;
    IdTCPClient1.Connect;
    IdTCPClient1.WriteStream(FileStream,True,True);
    IdTCPClient1.Disconnect
  Finally
    FileStream.Free;
  end;

end;

procedure TForm1.IdTCPServer1Execute(AThread: TIdPeerThread);
var
  FileStream : TFileStream;
begin
  {Server Side}
  FileStream := TFileStream.Create('c:\myfilenew.txt',fmOpenWrite);
  try
    AThread.Connection.ReadStream(FileStream);
  finally
    FileStream.Free;
  end;
  AThread.Terminate;
end;
0
 
rbohacCommented:
Actually it should be fmCreate not fmOpenWrite
0
 
rpmcdonaldAuthor Commented:
Would both server and client need to manually activated or would the server automatically know when a transmission was sent...
0
Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

 
rbohacCommented:
IDTCPServer has an active property. This would need to be set to true before it would accept connections. After that it would automatically accept (and multithread) new connections
0
 
rpmcdonaldAuthor Commented:
Sounds Great!! I wont be able to test it for a while, but thanks for the help
0
 
rbohacCommented:
Sure. Followup if you have any more questions about it.

Also, you can pass the filename with a few small changes:
procedure TForm1.Button1Click(Sender: TObject);
var
  FileStream : TFileStream;
  FileName   : String;
begin
  {Client Side}
  FileName   := 'c:\myfile.txt';
  FileStream := TFileStream.Create(FileName,fmOpenRead);
  try
    IdTCPClient1.Host := 'localhost';
    IdTCPClient1.Port := 12345;
    IdTCPClient1.Connect;
    IdTCPClient1.WriteLn(ExtractFileName(FileName));
    IdTCPClient1.WriteStream(FileStream,True,True);
    IdTCPClient1.Disconnect
  Finally
    FileStream.Free;
  end;

end;

procedure TForm1.IdTCPServer1Execute(AThread: TIdPeerThread);
var
  FileStream   : TFileStream;
  BaseFilePath : String;
begin
  {Server Side}
  BaseFilePath := 'c:\';
  FileName     := AThread.Connection.ReadLn;
  FileStream   := TFileStream.Create(BaseFilePath + FileName,fmCreate);
  try
    AThread.Connection.ReadStream(FileStream);
  finally
    FileStream.Free;
  end;
  AThread.Terminate;
end;
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now