Jump to content

MrCamarium

Members
  • Content Count

    13
  • Joined

  • Last visited

Community Reputation

0 Neutral

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. the two codes I used were working, in making the change it gives me the error I mentioned.
  2. Assembling the code like this: procedure TForm1.serverExecute(AThread: TIdContext); var clients: tlist; i: integer; messaggioprelevato, FileName: string; TFSFileIn: TFileStream; begin messaggioprelevato := AThread.Connection.IOHandler.ReadLn; showmessage(messaggioprelevato); clients := Server.Contexts.LockList;; try for i := 0 to connessi - 1 do try TIdContext(clients.Items[i]).Connection.IOHandler.WriteLn (messaggioprelevato); except end; finally begin TThread.Synchronize(nil, procedure begin showmessage('Arriva qualcosa...'); Filename := 'C:'; end); TFSFileIn := TFileStream.Create(FileName, fmCreate); try AContext.Connection.IOHandler.ReadStream(TFSFileIn); finally TFSFileIn.Free; end; end; end; Server.Contexts.UnlockList; end; It gives me this error: [DCC Error] Unit1.pas (59): E2003 Undeclared identifier: 'AContext'
  3. I tried this method: procedure TForm1.serverExecute(AThread: TIdContext); begin serverExecute1(AThread); serverExecute2(AThread); end; Even if it works it gives me problems. So to explain me better with the code: procedure TForm1.serverExecute(AThread: TIdContext); var clients: tlist; i: integer; messaggioprelevato: string; begin messaggioprelevato := AThread.Connection.IOHandler.ReadLn; showmessage(messaggioprelevato); clients := Server.Contexts.LockList;; try for i := 0 to connessi - 1 do try TIdContext(clients.Items[i]).Connection.IOHandler.WriteLn (messaggioprelevato); except end; finally end; Server.Contexts.UnlockList; end; I can remotely send messages. Instead with the code: procedure TForm1.ServerExecute(AContext: TIdContext); var FileName: string; TFSFileIn: TFileStream; begin TThread.Synchronize(nil, procedure begin Label1.Caption := 'Arriva qualcosa...'; Filename := 'C:'; end); TFSFileIn := TFileStream.Create(FileName, fmCreate); try AContext.Connection.IOHandler.ReadStream(TFSFileIn); finally TFSFileIn.Free; end; end; I can send files to a remote pc. Now the problem is that I can only use procedures once: Form1.ServerExecute1 (AContext: TIdContext); So the solution is to implement both functions in one code, but I was only able to do this: procedure TForm1.serverExecute(AThread: TIdContext); var clients: tlist; i: integer; messaggioprelevato, FileName: string; TFSFileIn: TFileStream;
  4. Thank you for your advice, on a scale between 1 - 10 I am 2 with Delphi. Mainly I deal with electronics, I do programming in my spare time, I would like to learn and I must say that in the last few years I have learned new things about Delphi, but if I succeed it is only with your help.
  5. Great! I didn't know this system could be used, I thought that the system should only be used with TButtons. Thank you!
  6. I have to combine these two codes, the first is for sending messages and the second for sending files: procedure TForm1.serverExecute(AThread: TIdContext); var clients:tlist; i:integer; messaggioprelevato:string; begin messaggioprelevato:=AThread.Connection.IOHandler.ReadLn; showmessage (messaggioprelevato); clients := Server.Contexts.LockList;; try for i:=0 to connessi-1 do try TIdContext(clients.Items[i]).Connection.IOHandler.WriteLn(messaggioprelevato); except end; finally end; Server.Contexts.UnlockList; end; procedure TForm1.ServerExecute(AContext: TIdContext); var FileName: string; TFSFileIn: TFileStream; begin TThread.Synchronize(nil, procedure begin Zilename := 'C:'; end); TFSFileIn := TFileStream.Create(FileName, fmCreate); try AContext.Connection.IOHandler.ReadStream(TFSFileIn); finally TFSFileIn.Free; end; end;
  7. I figured out where I was wrong, the code works fine. In the server program as destination I did not give him the folder but the name of the file. Thank you! However, if you can suggest me a method with which I can monitor the sending I would be grateful.
  8. I downloaded the libraries but couldn't find a guide that tells me how to update the components. Inside the Lib folder there is a * .Bat file corresponding to each version of Delphi. I launched Fullc_XE2.bat but when I reopen my IDE I find the same version of Indy 10.5.7.
  9. The test file is about 200K being local 127.0.0.1 should be fast transfer. At this point how do I know that the transfer is taking place? If I wanted to use a TProgressBar what should I do?
  10. I am using Embarcadero® RAD Studio XE Version 15.0.3890.34076 the version of Indy is 10.5.7 the code: procedure TForm1.ServerExecute(AContext: TIdContext); var FileName: string; TFSFileIn: TFileStream; begin TThread.Synchronize(nil, procedure begin Label1.Caption := 'Arriva qualcosa...'; Filename := Edit1.Text; end end; TFSFileIn := TFileStream.Create(FileName, fmCreate); try AContext.Connection.IOHandler.ReadStream(TFSFileIn); finally TFSFileIn.Free; end; end; Da errore: [DCC Error] Unit1.pas(46): E2029 ')' expected but 'END' found Correcting it like this: procedure TForm1.ServerExecute(AContext: TIdContext); var FileName: string; TFSFileIn: TFileStream; begin TThread.Synchronize(nil, procedure begin Label1.Caption := 'Arriva qualcosa...'; Filename := Edit1.Text; end; end; TFSFileIn := TFileStream.Create(FileName, fmCreate); try AContext.Connection.IOHandler.ReadStream(TFSFileIn); finally TFSFileIn.Free; end; end; It gives me an error: [DCC Error] Unit1.pas(45): E2029 ')' expected but ';' found 1.zip
  11. Thank you for the answer, The code: procedure TForm1.ServerExecute(AContext: TIdContext); var FileName: string; TFSFileIn: TFileStream; begin TThread.Synchronize(nil, procedure begin Label1.Caption := 'Arriva qualcosa...'; Filename := Edit1.Text; end end; TFSFileIn := TFileStream.Create(FileName, fmCreate); try AContext.Connection.IOHandler.ReadStream(TFSFileIn); finally TFSFileIn.Free; end; end; From errors in the compilation, however, even making the changes you suggested I still have a zero file. I am also attaching the file. 1.zip
  12. Customer side: procedure TForm1.Button1Click(Sender: TObject); begin try Label1.Caption := 'Connessione in corso...'; client.Port:=2630; client.Host:='127.0.0.1'; client.Connect(); except Label1.Caption := 'Errore Di Connessione'; end; end; procedure TForm1.Button2Click(Sender: TObject); begin client.Disconnect; Label1.Caption := 'Disconnesso'; end; procedure TForm1.Button3Click(Sender: TObject); var TFLFileOut: TFileStream; begin TFLFileOut:= TFileStream.Create(ToDownload.Text, fmOpenRead); Client.IOHandler.Write(TFLFileOut, 0, true); end; procedure TForm1.ClientConnect(Sender: TObject); begin Label1.Caption := 'Connesso'; Button1.Enabled := False; Button2.Enabled := True; end; procedure TForm1.ClientDisconnect(Sender: TObject); begin Label1.Caption := 'Disconnesso'; Button1.Enabled := True; Button2.Enabled := False; end; Server side: procedure TForm1.ServerExecute(AContext: TIdContext); var TFSFileIn: TFileStream; begin Label1.Caption := 'Arriva qualcosa...'; TFSFileIn:= TFileStream.Create(Edit1.Text, fmCreate); AContext.Connection.IOHandler.ReadStream(TFSFileIn); TFSFileIn.Free; end; procedure TForm1.FormCreate(Sender: TObject); begin server.DefaultPort:=2630; server.Active:=true; end; The program compiles correctly but the transferred file is zero. Da Cliente A Server.zip
×