When transferring numeric values across the internet, you have 2 things to bear in mind.
The first is the endianess, the order that bytes (or sometimes bits) appear in. Suppose you have the 32-bit value 0xAABBCCDD. Intel CPUs are little-endian machines, which mean those bytes would be stored as { 0xDD, 0xCC, 0xBB, 0xAA }. In other words, the least significant byte is stored at the lowest address. In a big-endian machine, the bytes would be stored as { 0xAA, 0xBB, 0xCC, 0xDD }, with the least significant byte at the highest address.
When transferring multi-byte integers between 2 machines, you have to ensure that they both interpret each others data correctly, even if they have different byte orderings. Thankfully, there is a standard called Network byte order, which is big-endian, and there are 4 useful functions for converting between host-order and network-order:
ntohl (Network to Host, long)
ntohs (Network to host, short)
htonl (Host to network, long)
htons (Host to network, short)
The long versions work with 32-bit integers and the short versions with 16-bit integers. As long as you always call *hton** before transmitting data across the network and call *ntoh** when reading from the network, data will be in the correct byte order.
Of course, the easiest way to get around this problem, especially since you have only 20 commands, is to just use single bytes, or chars.
The second problem you have to deal with is encoding. How are signed integers represented? Using a sign-bit? Twos complement? Again, you run in to problems when different platforms on the network use different representations. If you stick to unsigned types, you shouldn't really have a problem.
What you use to represent your commands in your program is entirely up to you. Just make sure that you define your protocol well and adhere to that when transmitting and reading data.
For example:
enum command_t { one, two, three }
void send_command(command_t c) {
send((unsigned char)c);
}
command_t read_command() {
return (command_t)recv();
}
void send(unsigned char c) { ... }
unsigned char recv() { ... }