I have been following Beej's Networking Tutorial 2.3.1 at (
http://www.ecst.csuchico.edu/~beej/guide/net/html/ ). I am currently using his last example on the "Synchronous I/O Multiplexing" selectserver.c but changed it to handle unconnected datagram sockets.
Currently my server just sends a "1" character to the client and the client responds with a double[32][4]. This is working fine. What am interested in is expanding the protocol to include other instructions. However Beej didn't cover any protocol programming. So am wondering if anyone knows any good tutorials on protocol programming. Or even a good protocol library/suite that can be easily used with Beej's selectserver.c.
Below is a protocol idea I have in mind for my application of a Real-Time Linux Cluster Monitor:
Server Commands:
"C" - Retrieve Group Of Hosts Processor Statistics
"M" - Retrieve Group Of Hosts Memory Info
"A" - Retrieve Both Group Of Hosts Processor & Memory
"X" - Shutdown Client Program
"G:1:2:3:4:5" - Change Group Of Hosts To Monitor
(Should I send integers since they're smaller than characters?)
Client Replies:
"C", double[32][4] // User, System, Nice, Idle
"M", double[32][8] // Used, Shared, Buffers, Cache, Swap Used, Load Avg (1min, 5min 15min)
(Is this the best way? Client sends a character then a double array? Or should I packaged them up in a structure? Is it possible to send a structure? Since we're sending 32x8 doubles would compression help lowering the network over-head? Is the character id reply unnessary? Would omitting the character id in the reply be okay?)
"A" struct {double[32][4]; double[32][8];}
"X"