Max Grobecker wrote:
> Now I'm puzzled: Of course, writing IPv4 octets with leading zeroes is not 
> very common.
> But: Is it officially prohibited or discouraged?

It was never defined in the rfcs, but by rfc convention, leading zeros
should probably be interpreted as decimal (e.g. rfc790).

The problem is, inet_aton() interprets leading zeros as octal, and on
any operating system which uses the bsd socket library, the address may
get converted into octal, or may not, depending on whether the program
is using inet_aton(), which assumes octal if there are leading zeros, or
getaddrinfo(), which will interpret as decimal in all cases, because
POSIX was a bit more careful about the definition.

In other words, you have no idea a priori what someone else's code will
do, so unless you're ok about your output being interpreted as random
garbage, you should avoid zero-padding at all costs.

Nick


Reply via email to