IP和端口判断(C#)
来源:互联网 发布:简谱识别软件 编辑:程序博客网 时间:2024/05/16 06:07
#region ip和port 有效性判断
/// <summary>
/// ip的有效性
/// </summary>
/// <param name="ip">IP</param>
/// <returns></returns>
public bool IP_YN(String ip)
{
bool YN = false;
if (System.Text.RegularExpressions.Regex.IsMatch(ip, "[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}"))
{
string[] ips = ip.Split('.');
if (ips.Length == 4)
if (System.Int32.Parse(ips[0]) < 256 && System.Int32.Parse(ips[1]) < 256
&& System.Int32.Parse(ips[2]) < 256 && System.Int32.Parse(ips[3]) < 256)
{
YN = true;
IniWriteValue("area", "ip", ip);
}
}
return YN;
}
/// <summary>
/// port有效性
/// </summary>
/// <param name="str">端口</param>
/// <returns></returns>
public bool PORT_YN(String str)
{
bool YN = true;
if (str.Length == 0)
{
YN = false;
}
else//没有非数字字符
{
for (int i = 0; i < str.Length; i++)
if (!char.IsNumber(str, i))
YN = false;
}
if (YN)//介于0-65535之间
{
if ((int.Parse(str) > 0) && (int.Parse(str) < 65535))
{
YN = true;
IniWriteValue("area", "port", str);
}
}
return YN;
}
- IP和端口判断(C#)
- 获取Socket的本地IP端口和远程IP端口的方法(C++)
- 理解IP和端口
- 理解ip和端口
- ip 和 端口
- 理解IP和端口
- IP地址和端口
- IP地址和端口
- ip和端口的解释
- IP地址和端口号
- UDP bind 端口和IP
- C/C++判断IP地址
- 【C++】判断IP地址有效性
- Linux c==网络编程的理论知识-dns端口和IP地址的作用(29)
- 怎样判断服务器的端口是否打开-------telnet ip port
- Apache IP和端口的绑定
- RMI IP绑定和端口固定
- 远程登陆MYSQL-指定ip和端口号
- ant打war包时找不到符号,找不到包的错误
- 跨平台移动开发实战(四)------Android开发环境网络连通解决方案
- 数据库恢复过程中查看恢复数据
- PB9 SQL端口修改后怎么连接
- 最近学C当中,仿写了2个函数。
- IP和端口判断(C#)
- java反射机制归纳总结
- 解决Asp.net MVC3下Web.config开启Custom Errors后Application_Error不触发问题
- Thread数目会超过MAXDOP的限制?
- MAC加密算法家族
- 如何在CSDN博客中的所贴的代码进行【代码块】显示
- SQL Server更改表数据类型View中Column数据类型没有相应改变
- Block 编程(翻译官方文档)
- @Deprecated