Coffee Pot ServerLinux

A second year university project was to implement a client and server pair, following RFC2324 - the Hyper Text Coffee Pot Control Protocol. The protocol is based on HTTP, and adds some request methods and headers so that coffee may be brewed autonomously.

The RFC has a number of ambiguities, and points were awarded if you could show your server or client working successfully with someone else's software. I thought that this project provided a good insight into 'defensive' programming - following the spec, but being flexible in what you will accept. For example, the RFC discusses the "Cream" addition, but it would be wise to accept "CREAM", "cream" and even "CrEaM".

Download

The compiled binary is avaliable with a config file here. As it is still an assessed piece of coursework, there is no source code and debug information has been removed from the binary.

Usage

Running ./coffee_server --help will give the following usage information:

$ ./coffee_server --help
Usage: ./coffee_server [OPTION]...
CoffeePot Server

Default host: localhost
Default port: 16000

Config file location: ./config.xml

-c, --client HOST   run as a client, connect to HOST
-s, --server        run as a server
-p, --port PORT     use this PORT
-d, --debug [LEVEL] run at debug LEVEL (off is 0, default is 10)
-?, --help          show this help
Providing a debug level of 1000 or above will not start the server, but will instead process some test-case requests.

Configuration

The coffee pot server is configured using an XML file. An extensive example is included in the download, but the following will provide an overview of what is required:
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <server>
  3.   <owner>CEMS</owner>
  4.   <port>16000</port>
  5.   <coffeepot id="0">
  6.     <location>3P11</location>
  7.     <addition_type name="milk" friendly="Milk">
  8.       <addition name="cream" stock="10" numeric="0">Cream</addition>
  9.       <addition name="whole-milk" stock="10" numeric="0">Whole Milk</addition>
  10.     </addition_type>
  11.     <addition_type name="sweetner" friendly="Sweetner">
  12.       <addition name="white-sugar" stock="10" numeric="1">White Sugar</addition>
  13.     </addition_type>
  14.   </coffeepot>
  15. </server>