ComputersNetworks

Client-server Delphi based on sockets

Today the topic in the sphere of information technologies, dedicated to the development and deployment of the client-server architecture, remains very relevant. This is due to the fact that information systems of various scales are increasingly used in various fields. In addition, the structure of any database is created by certain parameters, and in such a way that it is possible to work with it in normal mode only with the use of special applications. Therefore, the implementation of the client-server architecture is a very important task that arises before the information technology departments at various sites, the successful solution of which will allow the company to work optimally and smoothly.

A socket-based server

A server running a socket protocol allows simultaneous processing of requests from a large number of users. In this case, the administrator at any time can make adjustments to the settings to enter a limit on the number of simultaneously served users. By default, this parameter does not contain any restrictions.

After connecting the client to the server, a separate channel with a socket is opened, over which data is exchanged. However, the best and most secure way is to deploy a separate, separate process for each new connection.

Scheme of the architecture "Client-Server"

Let's consider in more detail the implementation scheme of the architecture, sequentially analyzing frequently used definitions:

1. Properties of ServerType and Port. In order for the user to be able to connect to the server, it is important to ensure that the port used by both the server and the client is the same. It is the purpose of this parameter that is made in the Port property. The connection type is determined by the ServerType parameter.

2. The process of opening a socket. To start a client-server session, it's important to open the socket and port. The Listen property is used.

3. Then the data is exchanged with the user. When shutting down, the client disconnects. With the corresponding system administrator command, the server exits, interrupting all established connections and terminating the process of waiting for new connections.

Application of TServerSocket in Delphi applications "Client-Server"

To send and receive information from the user, the OnClientWrite and OnClientRead events are used. In this case, you can interact with the user through a parameter such as ClientSocket. When working, the following methods and properties are often used:

- the number of currently connected users;

- number of active processes;

- number of free processes;

- port, host name and local IP address;

Unlock and lock the socket.

In conclusion, let's pay attention to the frequently used special property - Data. This property is applied in the following situation. Typically, the server is used to serve a large number of users, which means that there is a need to store information about each client, and this information must be bound to a specific socket. In such situations, the use of manual binding is very inconvenient, and therefore the Data property is widely used. However, it's important to remember that Data is a pointer, so it's important to check if all the rules for working with pointers (type indication, memory allocation, etc.)

Documentation

To date, there is very little literature on the development of Delphi client-server applications related to the development and use of sockets. Therefore, for a detailed study of this aspect, you can refer to the documentation on Linux and Unix-systems, tk. It describes in some detail the technology for deploying applications using sockets, however, usually in Perl or C ++.

Similar articles

 

 

 

 

Trending Now

 

 

 

 

Newest

Copyright © 2018 en.delachieve.com. Theme powered by WordPress.