In this article, the second part of a series, we will continue discussing how TCP/IP works in tandem with client server applications. Then, we are going to use this knowledge to implement the server part of an example client-server application with Delphi. We are also going to look at the various components that are available to create network applications.
Building a Server Application in Delphi - Application Support (Page 2 of 5 )
A server usually runs many different server applications, such as a mail, FTP or an IRC server. And each of these applications offer different services. For example, FTP is responsible for transferring files, a web server serves up web pages, and so on. TCP/IP needs to find a way to determine which incoming packet belongs to which application. For example, if a web browser requests a web page, it will have to be mapped to a web server application which is able to process and respond to the browser.
So how does TCP/IP manage this problem? TCP/IP manages this interface between networks and applications through logical channels called ports. Each port has a number by which it is identified. A port is used by both the server and client applications to communicate. There are approximately 65000 + ports available for use. Some are called well-known ports, which are reserved for certain services:
Service
Port number
SMTP
25
FTP
21
http
80
There are many other well-known port services; I would recommend that you google for a full list if you intend to write a lot of Internet-enabled applications. There are also free ports, which we will use for our example application.
I hope that the TCP/IP section of this article series has given you some background into how client server applications work behind the scenes. I have not covered a lot of it in detail, but the area that I covered should be enough to make it easy when we create example projects. It always helps to know a little bit more about what is going on in the background, so that you don't get stuck at the first sign of trouble. So far we have covered:
What a Client Application is and does.
What a Server application is and does.
What role TCP/IP plays in the client - server architecture.
Next we'll move on to creating client-server applications.