Delphi-Kylix
  Home arrow Delphi-Kylix arrow Page 4 - Using the Command Handler Method in Delphi
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Moblin 
JMSL Numerical Library 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DELPHI-KYLIX

Using the Command Handler Method in Delphi
By: Leidago
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 2
    2006-12-18

    Table of Contents:
  • Using the Command Handler Method in Delphi
  • Implementing the Second and Third Commands
  • Setting the Greeting
  • Indy clients
  • Building a More Appealing Client

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Using the Command Handler Method in Delphi - Indy clients


    (Page 4 of 5 )

    Clients are very simple to implement, because they basically just send a request and process the response. Dropping an idTCPClient component on a form with a button, an edit box and a memo is basically all it takes to create a client. Once you connect the client to a server, all you do then is send a command and wait for a response from the server, which you display in the memo.

    From our previous article we know that clients need a hostname or IP address and port number to connect to a server. So connecting to a client takes the form:

    with IndyClient do begin

    Host := 'myhostname.com' ; // You can use an IP Address here as well.

    Port := 6000; //This is where the server is listening

    Connect;

    Try

    // Read and write data here

    finally

    Disconnect;

    end;

    end;

    The code above shows the minimum requirements for creating a client application:

    • Set host property.
    •  Set port property.
    •  Connect.
    •  Reading/Writing.
    •  Disconnect.

    We also need to consider exception handling. In most cases when using client-server applications, the server application will be located at a remote place. Since you don't know if the server is running or not, you should make provisions in your code for any exceptions that may result from the server being inactive. All indy exceptions are descended from EIdException:

    try

    IdTCPClient1

     try

    // read/write here

    finally IdTCPClient1

    except

    on E: EIdException do begin

    ShowMessage('Indy Exception: ' + E.Message);

    end else begin

    ShowMessage('VCL Exception: ' + E.Message);

    end;

    end;

    More Delphi-Kylix Articles
    More By Leidago


       · All comments are welcome, especially from those of you who write client server...
     

    DELPHI-KYLIX ARTICLES

    - Building a Server Application for an Interne...
    - Building an Internet Access Control Applicat...
    - Client Dataset: Working with Data Packets an...
    - Using the Client Dataset in an N-Tiered Appl...
    - Using the Client Dataset in Two-Tiered Clien...
    - Using the Client Dataset in File-Based Archi...
    - Demystifying the Client Dataset
    - Working with INI Files in Delphi
    - Creating Data Link (UDL) Files in Delphi
    - Looking at the Details for an Invoicing Appl...
    - Invoicing in Delphi: Show Me the Money
    - Saving Images and Binary Files to a Database...
    - Saving Files to a Database using Delphi: Sav...
    - Creating CF Applications and Integrating a S...
    - Using Try and Finally to Help Prevent Memory...







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway