Solved

Simple idtcp Indy 10 example in Delphi 2009

Posted on 2008-10-27
6
7,036 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:ciuly
ciuly earned 100 total points
ID: 22816007
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org (http://seleniumhq.org) Go to that link and select download selenium in the right hand columnThat will then direct you to their downlo…
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 and create keystrokes in Netbeans IDE 8.0 for Windows.

707 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

15 Experts available now in Live!

Get 1:1 Help Now