问题描述
我想知道什么是Unix系统的主机名中的字符数。除了有可以在Unix的程序可以用来拨打该号码的任何定义的变量? (即,允许一个主机名的字符数)。
I am wondering what is the maximum number of characters for a host-name in a Unix system. In addition is there any defined variable that can be used in Unix programming to call that number? (i.e. number of characters allowed for a host-name).
我编程用C
推荐答案
您通常可以输入:
getconf HOST_NAME_MAX
另外,你可以大致包括limits.h中您的应用程序和阅读价值的定义。
In addition, you can generally include limits.h to your application and read the value of the define.
虽然POSIX标准说,它不能保证超过255个字节,这并不一定意味着每个实施将坚持这一点。
While the POSIX standard says it is guaranteed not to exceed 255 bytes, that does not necessarily mean that each implementation will adhere to that.
男人gethostname来获得更详细的信息。
man gethostname on your platform to get more detailed information.
这篇关于什么是字符在Unix的主机名的最大值是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!