Limits and Defaults

Your user code must allow for longer network addresses and host names.

A fully qualified hostname can be up to 255 characters, with each label being up to 63 characters (for details, see the RFC2181 clarification to the DNS specification). However, the underlying C++ code allows for 1,025, so allow for a host name of 1,024, to make your code safe. A fully defined IPv6 address, including port number, can be up to 65 characters.

The following is taken from a Microsoft header file, and agrees with other Internet descriptions.

// The totals are derived from the following data:
//  15: Ipv4 address
//  45: Ipv6 address including embedded Ipv4 address
//  11: Scope Id
//   2: Brackets around Ipv6 address when port is present
//   6: Port (including colon)
//   1: Terminating null byte
//
#define INET_ADDRSTRLEN  22
#define INET6_ADDRSTRLEN 65