Home arrow Delphi-Kylix arrow Sever Side Chat Application with Borland Delphi/Indy
DELPHI-KYLIX

Sever Side Chat Application with Borland Delphi/Indy


This article will get you started on building a chat application based on the client/server model. It will be able to handle all of the basics found in chat applications like Microsoft Messenger and others.

Author Info:
By: Jacques Noah
Rating: 4 stars4 stars4 stars4 stars4 stars / 23
December 26, 2005
TABLE OF CONTENTS:
  1. · Sever Side Chat Application with Borland Delphi/Indy
  2. · The Code
  3. · Receiving messages: listnames, all, takeshot, name, file
  4. · Handling Commands: Listnames, all, takeshot
  5. · Handling commands: name, file

print this article
SEARCH DEVARTICLES

Sever Side Chat Application with Borland Delphi/Indy
(Page 1 of 5 )


A downloadable zip of the COMPLETE source code for the application is available here.

Introduction

Most chat applications are based on a client/server model, i.e. the client logs on to a server, gets a list of other clients who are logged on and sends messages to them. When you decide to join a chat, the software program that you use connects to a server somewhere and allows you to ‘talk’ to other people who are connected to that server. 

Our chat application is also going to be based on client/server model.  What we are going to do in this tutorial is look at how the server enables clients to communicate. We are also going to look at how the server sends files to other clients, take screenshots and sends these back to your computer.  We will set up our own little communication protocol.

Requirements for the Server Application:

  • We want the server to be able to keep a record of every client on the chat.
  • We want it to be able to send files and take screenshots of connected clients.
  • We want it to send text to everybody or a single person (private chat), with the possibility of doing a three way chat.
What you need

You need to have Indy 9 or 10 installed. If you have Delphi 6 or above, then you can skip this section; otherwise go to www.indyproject.org and download the version appropriate to your Delphi version. I am using Delphi 7 and Indy 10.0.52. There are proper guides available on the indy site, on how to install Indy on your computer.

Let's get started!

Fire up Delphi and create a new application. Go to the indy server tab, select and add the idtcpserver (make sure that it is the idtcpserver and NOT the idsimpletcpserver or anything else), then go to the object inspector and change its name to ts. Now, the application itself will not be seen by the clients (people who log on to the server), so it is up to you as to how you want to decorate it.

The determining factor here is whether your server is going to have a fixed port number, in which case you can just hard code it into the server. Otherwise you will need to follow my design, which will be flexible in terms of port number assignment. To make the server flexible, add a tedit component and a label (available on the Standard Tab). Give the tedit the name edpor, and name the label Set Port Numbe. Also, add a tmemo. We will use this to display who logged on/off. I will explain below why we need a port number.

Port Number

The port number is used by the server application to listen for clients who want to join or log on to the chat. There are over 650000 port numbers available, but I would recommend you use any number from 4000 as some port numbers are reserved for other services such as SMTP on port 25, POP3 on port 110, HTTP on 80, and so on; be careful when choosing a port number for your server. Go to: http://www.i386.info/ports.htm  for a list of known ports and further information.

My server app, so far:


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...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




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