3.1
因为不同类型的套接字长度不同。IPV4和IPV6套接字长度固定,但Unix域结构和数据链路结构是可变长度的,需要一个参数记录结果的大小,直接传就是值传递了,需要传一个指针,以实现引用传递。
3.2
void指针只能用来传参数,不能对void类型指针加减和解引用
3.3
匆匆忙忙按自己的理解写了下, 也不知道对不对。。先这样吧
#include "../lib/unp.h"
#include <string.h>
int inet_pton_loose(int family, const char* strptr, void* addrptr){
if(family==AF_INET){
int res;
if((res=inet_pton(family, strptr, addrptr)<=0)){
printf("inet_pton failed, IPV4 address is %s\n",strptr);
struct