我已经创建了代码,用于将新套接字绑定到计算机的地址,以侦听特定端口上的传入连接。我正在使用getaddrinfo。这是最好的方法吗?将端口整数转换为字符串似乎毫无意义。有没有一种不需要sprintf就能做到这一点的方法?SOCK_STREAM; char portStr[6]; if (getaddrinfo
我的程序有以下警告,因为我认为出现了核心转储分段错误:
rc = getaddrinfo(svrHost, svrPort, &hints, &res);:12: note: expected ‘const char * restrict’ but argument is of type ‘short unsi