views:

69

answers:

2

I am currently upgrading our software to support ipv6 and in the meantime I'm expanding hostname/ip fields to the max hostname size. In sun documentation it seems like this can be up to 1025 (netdb.h:#define NI_MAXHOST 1025 - this is the recommended hostname allocation define), but when I pass a hostname of over 255 to getaddrinfo I get "getaddrinfo failed: memory allocation failure". I am testing on a Sol10 box. Ideas?

+3  A: 

NI_MAXHOST is for getnameinfo(), getaddrinfo() uses the MAXHOSTNAMELEN. (see here) , and that seems pretty much to be hardcoded - and there's little you can do about it.

Exactly why these differ I don't know, but see e.g. also here/here for some info on max host name lengths.

nos
A: 

You have no choice: this limit of 255 characters is the standard. Let me quote RFC 1123, section 2.1:

Host software MUST handle host names of up to 63 characters and SHOULD handle host names of up to 255 characters.

bortzmeyer