
网络编程
傻子与白痴
路漫漫其修远兮吾将上下而求索
展开
-
socket编程--连接服务器(用IP地址或域名)
bool ThreadObject::checkIP(QString host) { //判断IP地址合法性 QStringList ipsplit = host.split('.'); //判断是否为111.111.111.111的形式 if(ipsplit.length() !=4) return false; for(int n=0;n...原创 2019-07-26 14:13:20 · 4044 阅读 · 0 评论 -
socket编程之addrinfo结构体与getaddrinfo函数
2014年04月13日 16:56:06 hustfoxy 阅读数 7761 1. 概述 IPv4中使用gethostbyname()函数完成主机名到地址解析,这个函数仅仅支持IPv4,且不允许调用者指定所需地址类型的任何信息,返回的结构只包含了用于存储IPv4地址的空间。IPv6中引入了getaddrinfo()的新API,它是协议无关的,既可用于IPv4也可用于IPv6。getaddrinf...转载 2019-07-04 14:47:08 · 368 阅读 · 0 评论 -
C语言检查ip是否合法
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <stdbool.h> bool isVaildIp(const char *ip) { int dots = 0; /*字符.的个数*/ int setions = 0; /*ip每一部分总和(0...转载 2019-08-01 09:20:34 · 1095 阅读 · 0 评论