简体   繁体   English

套接字编程addrinfo结构

[英]socket programming addrinfo structure

In socket programming(I'm on Winsock, if that matters) does the socket type structure member value(ie STREAM) have to match that of the protocol structure member(ie TCP)? 在套接字编程中(如果重要,我在Winsock上),套接字类型结构成员值(即STREAM)是否必须与协议结构成员(即TCP)的值匹配? In the documentation of Winsock it says that these are only the possible values, that it implies 'well they don't have to match, necessarily(ie STREAM is to TCP, or DATAGRAM is to UDP)'. 在Winsock的文档中,它说的只是可能的值,这意味着“它们不一定必须匹配(即STREAM用于TCP,或DATAGRAM用于UDP)”。

If they do not necessarily have to match, under what circumstance will you be able to mismatch them? 如果不一定必须匹配它们,在什么情况下您将能够使它们不匹配? If they particularly have to match, why specify two structure members when really one value determines the value of the other? 如果它们特别必须匹配,为什么当一个值确实确定另一个的值时指定两个结构成员?

I suppose you refer to the pHints parameter of getaddrinfo() . 我想您是指getaddrinfo()pHints参数。 They strictly don't have to match, but if the combination doesn't make sense, you won't get any results. 严格来说,它们不必匹配,但是如果组合没有意义,您将不会获得任何结果。

But you can set one of them to 0 and only use the other one. 但是您可以将其中一个设置为0而仅使用另一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM