【发布时间】:2017-01-20 15:09:59
【问题描述】:
我正在浏览 msdn 的“Getting Started With Winsock”,他们打开一个带有参数的套接字
struct addrinfo *result = NULL,
*ptr = NULL,
hints;
iResult = getaddrinfo(
argv[1],
DEFAULT_PORT,
&hints,
&result
);
ptr=result;
ConnectSocket = socket(
ptr->ai_family, // Address Family (address families like ipv6 ipv4)
ptr->ai_socktype, // Type (Like tcp, udp ect)
ptr->ai_protocol // Protocol to use (0 = service provider chooses)
);
但是 binarytides "Winsock tutorial" 是这样的(他们使用的是 C,但我看到有人在 c++ 中这样做)
s = socket(
AF_INET ,
SOCK_STREAM ,
0
)
ptr-> 做什么? 为什么要使用它而不是像 AF_INET 那样设置它?
另外,如果您有空闲时间并且熟悉套接字,我将不胜感激。
【问题讨论】:
-
你没有表现出
ptr这么难说的东西。 -
@SamiKuhmonen aahhh 是的,刚刚编辑。
标签: c++ sockets winsock winsock2