https://forum.lazarus.freepascal.org/index.php/topic,60194.msg449534.html#msg449534
Why are you asking in this forum when you're using Delphi? There's almost certainly more appropriate places... as you should have realised by now, since you've been doing the same thing for months.
Try recompiling with FPC/Lazarus and more of us might be interested... :-)
MarkMLl
Ahh, I see, Let me download Lazarus then. Thanks for the heads up.
Why are you asking in this forum when you're using Delphi? There's almost certainly more appropriate places... as you should have realised by now, since you've been doing the same thing for months.
Now the Client sends a command to the server to execute a function (This works good) now, in the same vein, i want a scenario where it returns something like 'Done' once the server has executed the program and it should show on the Label on the Client that everything is fine.
procedure TForm3.Button1Click(Sender: TObject); begin IdTCPClient1.Socket.WriteLn('SayHello'); Label1.Caption := IdTCPClient1.Socket.ReadLn; end;
procedure SayHelloWorldMessageBox(); begin ShowMessage('Hello World!'); end;
AContext.Connection.IOHandler.Write('Done');
Why does it not send a message from the Server to the Client to Display that "done",
Now the Client sends a command to the server to execute a function (This works good) now, in the same vein, i want a scenario where it returns something like 'Done' once the server has executed the program and it should show on the Label on the Client that everything is fine.
The simplest solution is to just call ReadLn() after WriteLn(), eg:
procedure TForm3.Button1Click(Sender: TObject); begin IdTCPClient1.Socket.WriteLn('SayHello'); Label1.Caption := IdTCPClient1.Socket.ReadLn; end;
procedure SayHelloWorldMessageBox(); begin ShowMessage('Hello World!'); end;
Note that TIdTCPServer is multi-threaded, where the OnExecute event is fired in worker threads, but ShowMessage() is not a thread-safe function. It should never be called outside of the main UI thread. So, either use TThread.Synchronize() or equivalent to call ShowMessage() in the main UI thread, or else use a thread-safe function, such as Windows.MessageBox().
AContext.Connection.IOHandler.Write('Done');
You should call Socket.WriteLn() instead of Socket.Write(), otherwise the client won't know when the string ends, unless you close the connection (which you are not doing) after sending the string.Why does it not send a message from the Server to the Client to Display that "done",
It does (assuming ShowMessage() does not deadlock/crash the calling thread), but the client you have shown is not coded to read the message.
Thank you. Will try to see how to code a VNC now!
Thank you. Will try to see how to code a VNC now!
Hopefully using FPC/Lazarus :-)
MarkMLl
Yes. Its installed on my PC. I have started learning with it already. Thanks guys for the heads up