It's for historical reasons. In the early days of socket programming, struct in_addr
contained a union
of various structures so you could get to the individual bytes. This union
became unnecessary when subnetting and classless addressing came along, but switching out the struct
for a simple unsigned long
would break a lot of code, so it just stayed that way.
If you're interested in network programming and you haven't yet picked up a copy of UNIX Network Programming then I'd highly recommend doing so, it's a goldmine for little details like this.