Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Simple idtcp Indy 10 example in Delphi 2009

Posted on 2008-10-27
6
Medium Priority
?
7,219 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 400 total points
ID: 22816007
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 4

Accepted Solution

by:
dprochownik earned 1600 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses

660 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