Delphi
--
Questions
--
Followers
Top Experts
I Need a very Clear example of how to send & receive(commands and string)using indy TCP Client, Server Client ?
also the Server has a password to establish the connection from the client.
thank you for your time.
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
alsantos :)
- put TIdTCPServer component on your form
- adjust the port setting on the property inspector.
- for auto activation, set the property Active to True on the property inspector.
- Indy TCP server works in command/response mechanism, to add a command in your protocol,
click on property CommandHandlers property on your property inspector then add your commands there.
- On each Command you can define the command string and use the OnCommand event to define
your own actions.
- You can also use response (numericcode, text, etc) to standardize your responses.
Run your test server and test it first with a telnet application connecting to the defined ports.
For the client:
- Try the ReadLn and WriteLn methods from the TIdTCPClient component to read/write strings
from/to the server.
An example code is more difficult to be read... this explanation will help more, I think.
regards,
huferry






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
basic Chat should be enough
but what about the server password ?
"Lee_Nover"
chat example(string) will be good but what about the commands & the server password !
unit u_Client;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient;
type
TForm1 = class(TForm)
IdTCPClient1: TIdTCPClient;
Button1: TButton;
Button2: TButton;
lbCommunication: TListBox;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Button3: TButton;
Button4: TButton;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure IdTCPClient1Disconnected(S
procedure IdTCPClient1Connected(Send
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button2Click(Sender
begin
if IdTCPClient1.Connected then
try
IdTCPClient1.Disconnect;
except on E : Exception do
ShowMessage(E.Message);
end;
end;
procedure TForm1.Button1Click(Sender
begin
lbCommunication.Items.Clea
with IdTCPClient1 do
begin
Host := Edit1.Text;
Port := StrToint(Edit2.Text);
try
Connect;
lbCommunication.Items.Add(
except on E : Exception do
ShowMessage(E.Message);
end;
end;
end;
procedure TForm1.Button3Click(Sender
var
LCommand, LInString : String;
begin
LCommand := Edit3.Text;
with IdTCPClient1 do
begin
try
WriteLn(LCommand);
LInString := ReadLn;
lbCommunication.Items.Inse
lbCommunication.Items.Inse
except
on E : Exception do
ShowMessage(E.Message);
end;
end;
end;
procedure TForm1.IdTCPClient1Disconn
begin
lbCommunication.Items.Inse
end;
procedure TForm1.IdTCPClient1Connect
var
LString : String;
begin
LString := IdTCPClient1.ReadLn;
lbCommunication.Items.Inse
lbCommunication.Items.Inse
end;
procedure TForm1.Button4Click(Sender
begin
with IdTCPClient1 do
begin
try
WriteLn('Password alsantos');
lbCommunication.Items.Inse
lbCommunication.Items.Inse
except
on E : Exception do
ShowMessage(E.Message);
end;
end;
end;
end.
alsantos ;)

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
alsantos
mido@ksaguys.com
but could you explain what do you mean by
except on E : Exception do
when it will do the except ?






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
I use try/except to protect the code. So, I use:
Try
.... // it will try the code here, but it can generate an error, for example
// the IdTCPClient1 isn't connected to a server.
// so it will generate an error and the Except will catch this error
// and show a message on the screen with the cause of this error
{ here the code that can generate an exception(error) }
Except
On E: Exception do
showmessage(E.Message); { here catch the error an show the error message }
alsantos
alsantos :)
alsantos

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
you really deserve A :)
here you go...
alsantos
Thanks... naru@eclipticdreams.com






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
procedure TForm1.Button1Click(Sender
begin
try
IdTcpServer1.DefaultPort:=
IdTCPServer1.Active := true;
ListBox1.Items.Append('Ser
except on E : Exception do
ListBox1.Items.Append('Ser
end;
end;
could u also send me the source code..? nhatiboy@hotmail.com
thanx in advance

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
^(~,~)^
Could you provide me with any tips on how to design this. I have never programmed in Delphi before and am a complete newbie. But I understand all about network management.
The information will be sent to a Server every X seconds and any changes should be sent to the monitored devices, such as traps. I would be very grateful.
Thanks
Eilis
Can you send me the source code from alsantos about indy client server, caused of alsantos account has been closed. My email japriku2000@yahoo.com
Thanks






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Can u send me a compiled program to email : drago666@abv.bg
Thanks
Could you send me the source code to email: dunglq78@gmail.com
thanks alot
Delphi
--
Questions
--
Followers
Top Experts
Delphi is the most powerful Object Pascal IDE and component library for cross-platform Native App Development with flexible Cloud services and broad IoT connectivity. It provides powerful VCL controls for Windows 10 and enables FMX development for Windows, Mac and Mobile. Delphi is your choice for ultrafast Enterprise Strong Development™. Look for increased memory for large projects, extended multi-monitor support, improved Object Inspector and much more. Delphi is 5x faster for development and deployment across multiple desktop, mobile, cloud and database platforms including 32-bit and 64-bit Windows 10.