Home arrow Delphi-Kylix arrow Page 3 - Using the Command Handler Method in Delphi
DELPHI-KYLIX

Using the Command Handler Method in Delphi


In the previous article, we discussed the various ways in which we can create indy servers. Picking up from where we left off, in this article we are going to build a server application using the CommandHandler method.

Author Info:
By: Leidago
Rating: 5 stars5 stars5 stars5 stars5 stars / 2
December 18, 2006
TABLE OF CONTENTS:
  1. · Using the Command Handler Method in Delphi
  2. · Implementing the Second and Third Commands
  3. · Setting the Greeting
  4. · Indy clients
  5. · Building a More Appealing Client

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Using the Command Handler Method in Delphi - Setting the Greeting
(Page 3 of 5 )

Now we need to set the greeting text that will be displayed when a client first connects. This is entirely optional; your application will function perfectly fine with or without it.  Click on the idCMDTCPServer1 component and go to its greeting property. Click on the plus sign and go to the "Text" option. Enter "Welcome to my Server" and click OK. Also, add "idcommandhandlers" to the form's uses clause.

Double click on the form's on create event and add the following code:

procedure TForm1.FormCreate(Sender: TObject);

begin

idcmdtcpserver1.DefaultPort:=6000;

idcmdtcpserver1.Active:=true;

end;

This procedure sets the port at which the server will listen for connections from clients and activates the server. The port number is completely random; you can set any non-known number here. We've covered port numbers in the previous article, so check to see which numbers you should and should not use.

Compile and run your project. While the application is running, go to your DOS prompt and start telnet by typing "telnet." You should now see the telnet prompt. Type "open localhost 6000".

I use "Localhost" because I'm running the server application on my local machine. If you are on a network, use your network IP address instead.  I use the 6000 number because that's where we set the server to listen for connections. Press return and you should see something like this:

I've asked for a quote by typing "Aquote" and pressing the return key. In next screen I ask for today's date and I get:

Next I close down my connection:

It is very easy to implement your own protocol with indy servers, once you understand how indy works. CommandHandlers makes this process even easier because of their flexibility and properties, most of which we have not covered here. Hopefully this introduction will inspire you to start experimenting with this technology.


blog comments powered by Disqus
DELPHI-KYLIX ARTICLES

- Loading an XML Document into the DOM
- Delphi Wrapper Classes and XML
- Delphi and the DOM
- Delphi and XML
- Internet Access: Client Service
- Finishing the Client for an Internet Access ...
- The Client for an Internet Access Control Ap...
- User Management for an Internet Access Contr...
- Important Procedures for an Internet Access ...
- Server Code for an Internet Access Control A...
- Constructing the Interface for an Internet A...
- 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...

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 8 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials