In the Ancient Times, there were "classes" of subnets, where the first one, two,
or three bytes of the address was the network part.
To remedy this, The Powers That Be allowed for the netmask to be an arbitrary
number of bits, not just 8, 16, or 24. So you might have a netmask of, say 255.255.255.252, which is 30 bits of network, and 2 bits of host
allowing for four hosts on the network. (Note that the netmask is ALWAYS
a bunch of 1-bits followed by a bunch of 0-bits.)
Beej's Guide to Network Programming
Basically, you'll want to convert the numbers to Network Byte Order before
they go out on the wire, and convert them to Host Byte Order as they come in off
the wire.