Synapse send file lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- xinyiman · 2015-05-22 13:15 hello guys, I need to understand how to send files with my class. It works well for sending strings. But I must also send and receive files. Who tells me how to do? thanks Code: [Select]unit Unit_Client_TCP; {$mode objfpc}{$H+} interface uses   Classes, SysUtils, blcksock; type    { TTCPClient }    TTCPClient=class        private               sock: TTCPBlockSocket;               buffer: String;               ErrorStr: string;        public          constructor Create(Host: string; Port: string);          function GetErrorStr(): string;          function SendString(str: string): boolean;          function GetString(): string;          destructor Free();    end; implementation { TTCPClient } constructor TTCPClient.Create(Host: string; Port: string); begin   Self.Buffer:='';   sock := TTCPBlockSocket.Create;   sock.Connect(Host, Port);   // Was there an error?   if sock.LastError <> 0 then   begin        Self.ErrorStr:=sock.LastErrorDesc;   end; end; function TTCPClient.GetErrorStr: string; begin      result:=Self.ErrorStr; end; function TTCPClient.SendString(str: string): boolean; begin      sock.SendString(str + #13#10); end; function TTCPClient.GetString: string; begin      buffer := sock.RecvPacket(2000);      result:=buffer; end; destructor TTCPClient.Free; begin      Self.sock.CloseSocket;      Self.sock.Free; end; end. ---------------------------------------------------------------------- xinyiman · 2015-05-22 13:16 And also if anyone knows how to encrypt the connection safely. ---------------------------------------------------------------------- balazsszekely · 2015-05-22 15:29 Open blcksock.pas. You will find the following methods:    -SendStream    -SendStreamRaw    -SendStreamIndy    -RecvStream    -RecvStreamRaw    -RecvStreamIndy   Load the file to stream then send it through socket. If you want a progressbar send the files by chunk.