主机名的有效字符? [英] Valid characters of a hostname?

查看:250
本文介绍了主机名的有效字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

主机名的有效字符是什么?就像是联网计算机或网络域.

What are the valid characters of a hostname? This would be something like a networked computer or a web domain.

在上下文中,我正在编写一个连接到远程服务器的PC游戏.所以我有一个用于主机名的字段和一个用于端口的字段.显然,端口是短范围内的数字,但是我需要知道所有可能的主机名字符是什么(以及可能需要的其他任何模式-主机名是否需要以字母开头?).

To put it in context, I am writing a PC game which connects to a remote server; so I have a field for hostname and a field for port. Obviously the port is a number in the Short range, but I need to know what all the possible hostname characters are (and any other pattern that might be required - does a hostname need to start with a letter?).

主机名的示例包括localhostgoogle.com.

推荐答案

检出此 Wiki ,特别是有效主机名的限制

主机名由一系列带点的标签组成,所有域名也是如此.例如,"en.wikipedia.org"是一个主机名.每个标签的长度必须在1到63个字符之间,并且整个主机名(包括定界点而不是尾随点)最多可以包含253个ASCII字符.

Hostnames are composed of series of labels concatenated with dots, as are all domain names. For example, "en.wikipedia.org" is a hostname. Each label must be between 1 and 63 characters long, and the entire hostname (including the delimiting dots but not a trailing dot) has a maximum of 253 ASCII characters.

协议的Internet标准(要求注释)要求组件主机名标签只能包含ASCII字母"a"至"z"(不区分大小写),数字"0"至"9",和连字符('-'). RFC 952 中主机名的原始规范要求标签不能以数字或连字符,并且不能以连字符结尾.但是,随后的规范( RFC 1123 )允许主机名标签以数字开头.不允许使用其他符号,标点符号或空格.

The Internet standards (Requests for Comments) for protocols mandate that component hostname labels may contain only the ASCII letters 'a' through 'z' (in a case-insensitive manner), the digits '0' through '9', and the hyphen ('-'). The original specification of hostnames in RFC 952, mandated that labels could not start with a digit or with a hyphen, and must not end with a hyphen. However, a subsequent specification (RFC 1123) permitted hostname labels to start with digits. No other symbols, punctuation characters, or white space are permitted.

这篇关于主机名的有效字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆