Internet Programming for
My Telematics Course at the University of Wales

I was very excited to have the opportunity to do this assignment. For one, it accomplished something that seemed really impressive (impressive to me, at any rate), but was very easy to do. For two, I learned something completely brand-new and useful and cool in a very short amount of time.

The assignment:

The purpose of the assignment was to gain practice in programming Internet applications in C. The requirements were to write two programs, a client and a server, which used socket interfaces to TCP/IP networking. The server was meant to be a drinks server. In other words, it accessed a database which stored recipes of various drinks. The client could connect to the server and request information from the server's drinks list.

Details of the drinks server:

Each record in the database of drinks contained five fields as follows:

  1. The name of the drink
  2. A liquid ingredient of the drink
  3. A second liquid ingredient of the drink
  4. An item used to decorate the drink
  5. The mystery ingredient of the drink

All data passed between the client and server was in the form of character streams. The messages sent from the client consisted of a single letter representing a request, followed immediately by a three digit number, representing a record number. The letters used were:

  • N or n -- request the name of the drink
  • I or i -- request the first liquid ingredient
  • B or b -- request the second liquid ingredient
  • D or d -- request the decorative item
  • M or m -- request the mystery ingredient
  • R or r -- (followed by the number 000) request the total number of records in the database

The code:

Here is my source code for both the client and server programs I wrote for the assignment. Please note that much of the code used to establish sockets and network connections was taken from notes in class. This is what made my job so easy. The rest only took me a few hours to work out.

Source code for the drinks server.

Source code for the drinks client.