Protocol version 0
~~~~~~~~~~~~~~~~~~

Cmd   Client-->Server       Server-->Client
---   -------------------   --------------------
  0   Listen request        Listen response
  1                         Sensor value update
  2   Sensor list request   Sensor list response
  3   Shm request           Shm response


client: argus_connect()

+ Client opens UNIX domain socket.
+ Client writes protocol version code to server.
  - byte 0: (unsigned char) client version
+ Server responds with same or lesser version code.
  - byte 0: (unsigned char) common version
+ Client and server use the least-common-denominator protocol version.

client: argus_disconnect()
client: [shutdown]

+ Client closes UNIX domain socket fd.
+ Server removes client from connected list.

server: [shutdown]

+ Server closes UNIX domain socket fd.

client: argus_listen()

+ Client sends list of sensors to listen to.
  - (unsigned char) packet length (3 + sensor count + sum of name lengths)
  - (unsigned char) command (0)
  - (unsigned char) sensor count
  - (unsigned char) first sensor: name length
  - (char array)    first sensor: name characters; no terminating \0
  - (unsigned char) second sensor: name length
  - (char array)    second sensor: name characters; no terminating \0
  - etc.
+ Server sends status flags.
  - (unsigned char) packet length (2 + sensor count)
  - (unsigned char) command (0)
  - (unsigned char) first sensor: status
  - (unsigned char) second sensor: status
  - etc.
  - Status codes: 0 = success, 1 = sensor not found, 2 = duplicate sensor
+ If there were no errors, server hereafter continually sends value updates on
  the named sensors.  It immediately sends the current values and then sends
  further packets only when at least one of the named sensors changes, up until
  the client disconnects or changes its listen list.
 
server: [value change on sensor]

+ Server sends new values for all sensors client is listening to.
  - (unsigned char) packet length (2 + sensor count)
  - (unsigned char) command (1)
  - (unsigned char) first sensor: value
  - (unsigned char) second sensor: value
  - etc.

client: argus_sensors()

+ Client sends sensor list request.
  - (unsigned char) packet length (2)
  - (unsigned char) command (2)
+ Server sends list of all available sensors.
  - (unsigned char) packet length (3 + sensor count + sum of name lengths)
  - (unsigned char) command (2)
  - (unsigned char) sensor count
  - (unsigned char) first sensor: name length
  - (char array)    first sensor: name characters; no terminating \0
  - (unsigned char) second sensor: name length
  - (char array)    second sensor: name characters; no terminating \0

client: argus_open_shm()

+ Client sends shm request.
  - (unsigned char) packet length (2)
  - (unsigned char) command (3)
+ Server sends shm key.
  - (unsigned char) packet length (2 + sizeof(key_t))
  - (unsigned char) command (3)
  - (key_t)         shm key

client: argus_close_shm()

+ Client closes shm with shmdt().  This doesn't involve the socket.

