本文介绍了如何验证主机名(可能是IP)和端口号(CString)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有主机名和端口编辑框的HTTP代理配置对话框。

I have an dialog for HTTP proxy configuration with hostname and port edit boxes.

我的问题是如何验证用户输入的正确主机名和端口?

My question is how can I validate user input for correct hostname and port?

可能是我必须使用一些正则表达式进行主机名验证还是有一些有用的MFC或WinAPI函数?端口的最大正确数字是多少?

May be I have to use some regular expression for hostname validation or there is some helpful MFC or WinAPI function? What is the maximum correct number for port?

推荐答案


  1. 端口号是来自1-的无符号短号65535,1024以下的端口保留用于系统服务http,ftp等。

  2. 我不相信你可以(或应该),尤其是当您有本地化主机名时。

  1. Port number is an unsigned short from 1-65535, ports under 1024 are reserved for system services http, ftp, etc.
  2. I don't believe that you can validate host name (or should) especially when you have locallized host names.

这篇关于如何验证主机名(可能是IP)和端口号(CString)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 07:39