What makes you think that 1.1.1 or 9.9.9
are invalid representations of IP addresses? They *are* valid.
If you're using the dotted number notation, there are at most 4
numbers. But if there are 3 or 2, the one or two numbers before
the last are assumed to be 0. Hence, gethostbyname is quite
correct, and you are incorrect by assuming to have it fed
illegal input.