[ back to toc ]

Help on Railway reservation system using C and unix

Date: 2002/05/08 09:13

Q:
We have a project to be done in C and unix which involves the railway
reservation system.
It is to be implementd using C as the Front end with unix as the server
side
The main part of our project is that we have to block two users
simultaneously trying to book a same ticket.
We have used C files as the database.
How do we interface c with Unix
We are using Turbo C and Linux

*NAME-DELETED*
A:
To be honest: I would not do it using a C fornt-end. I would rather do it
using Web application (maybe CGI, or something more powerful). I assume
that this is going to be home-work (getting to the end of the year many
such questions arise altough there was the hole semester to do the work. I
know I was student, and t students I teach come up with the questions
these days... It is not a problem.)

What you need is writing a server program and a client program. The two
programs have to communicate using some inter process communication. There
are several possibilities: pure socket implementation, CORBA, RPC adn so
on. I have only experience with socket programmign, all others are higher
level interfaces built on top of socket programming.

To learn socket programming read Beej's Guide (seek google for it, easy to
find).

The easiest solution on the server side is to write a program that runs
started by 'inetd'. This way your program can also be tested on the
command line typing the characters expected to come over the net and
seeing the characters answered by the program on the screen. (Program
started by inetd get network input on stdin and should send stdout the
answer.)

Ensuring that you do not sell a ticket twice you have to use some locking
method. This can be based on pthread locking mechanism if you implement a
single process. multi-thread daemon (not the inetd solution) or file
locking (fcntl or flock BSD style system call).

Regards,
Peter

[ back to toc ]