It is true that Software Programming is a branch of Computer Science about which I’m pretty enthusiastic. But I’m very excited at the times when I learn something new and innovative on programming. Such a period of learning of new issues on programming was when I began to wonder about the way the Internet works. My questions were related to the client – server architecture model (on whose base the Internet and its services has been designed), how web applications is in practice implemented and how I could implement an Internet service on my own.

After much studying and practical experimentation, I realized at last how the Internet and web programming work. Then, I started a new internet service which can provide random text messages. The name of this service is ‘gtrm’.

Images of the programs that implement the service:

As we already mentioned, the service ‘gtrm’ provides us with the option to display random text messages.

Initially, the service ‘gtrm’ was designed without supporting networking, i.e. operating only locally and any PC should be equipped with the local program ‘gtrm-local’ and the file of random text messages. There was no client or server program, only the local program ‘gtrm-local’ which performed the task of fetching a random message from the file with the random messages to display at the standard output.

But then, based on client – server architecture and using network programming, we supported network communication ability as well. In this case, there is a server program ‘gtrm-server’, which serves the requests of clients. The server is equipped with the file of random messages and sends the various random messages to clients.

But the process of fetching random text messages is made by the local program ‘gtrm-local’ which was there from the start. So, the server ‘gtrm-server’ only performs network communication with the client(s) ‘gtrm-client’.

These three programs, the local ‘gtrm-local’, the server ‘gtrm-server’ and client ‘gtrm-client’ as a whole make up the service ‘gtrm’.

A brief explanation of each of the programs:

a) ‘gtrm-local’

The main function of the local program ‘gtrm-local’ is simple. In every execution, it reads data from the corresponding input. Then it stores them in an internal data structure (binary tree) for better management and selects a random line of data from this structure. Finally, it returns the random line to the appropriate output. The source and destination can be anything. For example, the source could be data entered by the user during execution through the keyboard, it can be a text file or it can be the output of another application. Similarly, the output can be sent on screen or to an output file or even the input of another application.

Also, during execution, the program can display various verbose messages that help us and explain its actions. If the user wants to select more than one line of data, then there is this possibility also.

As we see, the local program ‘gtrm-local’ may work in different ways. Before the execution, we define what the input, output, what algorithm producing random position we want to select (based on this algorithm a random line is selected from the file), if you want to display verbose messages, and, of course, the number of lines of data we want to extract.

We could have lines duplication in the input. In such a case, the local program ‘gtrm-local’ behaves accordingly, retaining only lines that are unique. Also, it checks the validity of the various data entered by the user if he wants to adjust and determine the mode of operation.

If there are blank lines of data or when data lines are comments, then they are ignored.

It is worth mentioning that the service ‘gtrm’ also includes a program with GUI support. The program is called ‘gxrm-local’ (GNU X Random Message) and uses the local ‘gtrm-local’ for fetching and displaying of random text messages.

b) ‘gtrm-server’

The server ‘gtrm-server’ sends random lines of data to any client ‘gtrm-client’ who has sent a relevant request. The server works as a process in the background but it is unrelated to the known background processes. It is really not connected to any terminal and has no parent process. This converts it to a ‘daemon’ process and make it connect to the first process during the execution of the kernel of the operating system. This makes it a real server as it is fully isolated from any user environment.

Now, using the client – server model, there is only one file of random text messages stored on the server side. And not every user needs to have this file, only the server ‘gtrm-server’.

As a result, all clients have the same updated data source.

The above reasoning leads us to the following conclusion:

The server ‘gtrm-server’ implements its relevant work, then receives the data from the local ‘gtrm-local’ and sends them to ‘gtrm-client’ clients whom it serves.

Basic features of the server:

– Simultaneous clients service in different processes
– Good errors and exceptions management interface
– Protection of critical sections at runtime
– Run as ‘daemon’ like other services servers
– Store client information (IP address, connection date)
– Holds information accessible only by the administrator
– Inform the system administrator for significant errors
– Capability to run only by the system administrator
– Multiple use at a fixed IP address and TCP port
– Only one server can be run at a time
– Good handling and release of terminated processes
– Management of system signals that appear unexpectedly
– Management of shell arguments and configuration support
– Support verbose messages display during execution
– Use of local ‘gtrm-local’ to obtain random messages

c) ‘gtrm-client’

The client ‘gtrm-client’ sends a request to the server program ‘gtrm-server’ to obtain a random line of data.

Future objectives:

Implement a specific protocol:

By using a specific protocol each client ‘gtrm-client’ could ask a server ‘gtrm-server’ for more than one text messages from different classes in any particular order, with some specific numbering. All this requires commands transmitted from the client ‘gtrm-client’ to the server ‘gtrm-server’, as well as compliance with certain rules.

For more information you can get the same service: