Solved

Simple idtcp Indy 10 example in Delphi 2009

Posted on 2008-10-27
6
7,049 Views
Last Modified: 2013-11-23
Hi experts,

I´m trying to learn the idtcp indy components, i searched a little but all examples that i found i could´t run in my system, that is delphi 2009 with indy 10.

I want a simple example to transmit and read a simple string, no commands,no files, no nothing, i want just a start. The example must be like drop an edit and a idtcp then do this, then do that, step by step will be much apreciated.

Thank you very much.

0
Comment
Question by:arreegua
6 Comments
 
LVL 5

Expert Comment

by:wd123
ID: 22812855
0
 
LVL 2

Author Comment

by:arreegua
ID: 22813110
"I want a simple example to transmit and read a simple string, no commands,no files, no nothing, i want just a start. The example must be like drop an edit and a idtcp then do this, then do that, step by step will be much apreciated."

Sorry i need a simple example, don´t want anything with ssl.
0
 
LVL 28

Assisted Solution

by:2266180
2266180 earned 100 total points
ID: 22816007
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Accepted Solution

by:
dprochownik earned 400 total points
ID: 22817160
If you want to run samples you have found before I advice you an article about upgreading from Indy9 to 10: http://conferences.codegear.com/article/32160
In fact, in most cases there are only few simple steps to make this code working.

If you want direct sample, here you have one.
Create two Delphi projects, one for server and one for client.

SERVER:

On server main form put only TidTCPServer component and change its properties:
  • DefaultPort = 3080 (for example)
  • Active = true (Server will be active since application start)
For TidTCPServer handle event OnExecute as:

var
  vClientMessage: String;
begin
  try
    //Getting message from client
    vClientMessage := AContext.Connection.IOHandler.WaitFor(#13);

    //Logging
    self.Caption := vClientMessage; //Or do with that string whatever you want to

    //Sending response
    AContext.Connection.IOHandler.WriteLn('Server response');
 
  finally
    //Closing connection
    if AContext.Connection.Connected then
      AContext.Connection.Disconnect;
  end;

CLIENT:

On client main form put TidTCPClient and TBitBtn components.
For TidTCPClient component change properties
  • Port = 3080 (it have to be the same port as in server application)
  • Host = '127.0.0.1' (it is computer you want connect to. 127.0.0.1 is equal localhost, and means your own computer)
handle TBitBtn.OnClick event as:

  IdTCPClient1.Connect;
  try
    IdTCPClient1.IOHandler.WriteLn('Client message');
    Self.Caption := IdTCPClient1.IOHandler.ReadLn;
  finally
    IdTCPClient1.Disconnect;
  end;

Now when you run both of them, and click on Client App on the button, then Client will send to server message 'Client message'. Server will show it in its form caption, and response to client string 'Server response' which Client will show in its form caption.

I hope it's clear enough.


0
 
LVL 2

Author Comment

by:arreegua
ID: 22824339
Thank you Very Much Ciuly and dprochownik.

The example that ciuly send me was exactly what i want but with a few errors to run with  delphi 2009 and indy 10(something with maxlines and lack of iohandler.writeLn) but it was ok, and i did the minor fixes to run following the dprochownik link to update from indy 9 to indy 10. Thank you very much Ciuly.

I ll Split points to reward the Ciuly efort but dprochownik answer was very complete, if i could i would give 500 point to every body.

Thank you very much both of you, when i grow up i want to be like u two , kakakak

cya guys thankyou again
0
 
LVL 2

Author Closing Comment

by:arreegua
ID: 31510298
Thankyou guys, exactly what i want
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now