
[tcpcliserv]
v 1.0.0
Consider the following client server architecture:
Clients Ci send messages to two servers S1 and S2 through a MSQ, created beforehand by S1.
For each message extracted from the MSQ, the servers fork a process Pi. Process Pi does the requested job, sends the result to client Ci via the MSQ, and kills itself. Client Ci displays the result.
The servers and processes Pi communicate via pipes. If there are several pending messages, the servers fork as many processes Pi as required to do parallel processing.
The messages are made of:
The server S1 extracts the messages made of one or two numbers. Process Pi computes:
The server S2 extracts the messages made of words. Process Pi converts the word in lowercase.
To do:
As the system used to create this application handles the message queues at the kernel level, it was not possible to fully comply with the subject.
The following changes have been carried out:
Three types of clients send messages to three types of servers through three TCP/IP sockets on three different ports.
The messages are made of one integer, two integers, or a word.
Client1 and server1 deal with all types of requests on port 9877. Client2 and server2 deal with numbers on port 9878. Client3 and server3 deal with words on port 9879.
There can be as many clients as the system supports on each server.
For each message received through the socket, the server forks a new process. The process does the following job:
The results are sent by the child process to the client through the socket. A signal catches the end of the child process. A call to select synchronizes the requests.
An attempt has been made to handle accentuated characters, but it is obviously system-dependent.
Mac OS X users
Requirements:
Installing:
Compiling:
Other users
Requirements:
Installing:
Compiling
Mac OS X users
Open Terminal and go to the build folder inside the project folder
Launch the server with: ./tcpserv -a
Launch the client with: ./tcpcli -a 127.0.0.1
Other users
Go to the tcpservcli folder
Launch the server with: ./tcpserv -a
Launch the client with: ./tcpcli -a 127.0.0.1
Read the messages in server and client to learn more about using them.
The application was written on an iMac 1Go RAM with system MacOS 10.2.4, enhanced with the latest Developer Tools and with XFree86.
It was tested on the iMac and a PowerPC G3, both connected via a switch to an ADSL modem and sharing the same Ethernet connection.
The tests on the G3 were made while connecting it to the iMac via ssh and X11 forwarding.
The code was edited with Project Builder.
Documentation was elaborated with Doxygen.
The graphics were created with AppleWorks.
Code
Heavily inspired from the late W. Richard Stevens
iMac, G3, MacOS 10.2.4, Developer Tools, Project Builder, AppleWorks
Ports on Mac OS X of Unix Open Sources
XFree86: XFree86 Project Inc., Jeffrey Whitaker(maintainer)
Doxygen: Dimitri van Heesch <http://www.doxygen.org>, Thomas Kotzian(maintainer)
The indefatigable guys of fink-users and fink-beginners mailing lists among others:
Alexander Hansen
Martin Costabel
Ben Hines
The following forums which help to sort out some specific questions on C, sockets and unix tools:
dBForums: comp.unix.programmers and comp.lang.c
BSDForums: general BSD discussions
Others
People who helped me and whose names I unfortunately forgot.