Re: socket arguments
- From: "Alan J. McFarlane" <alanjmcf@xxxxxxxxxxxxxxxxx>
- Date: Mon, 16 May 2005 20:29:16 +0100
In article news:%2317L4ZKWFHA.3184@xxxxxxxxxxxxxxxxxxxx, Arkady Frenkel
wrote:
> "Arkady Frenkel" <arkadyf@xxxxxxxxxxxxxxxx> wrote in message
> news:uaHUnNKWFHA.3864@xxxxxxxxxxxxxxxxxxxxxxx
>> <FrankNatoli@xxxxxxx> wrote in message
>> news:1116085097.500821.53590@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>>> Does a second socket() argument of SOCK_DGRAM imply a third socket()
>>> argument of IPPROTO_UDP? And does SOCK_STREAM imply IPROTO_TCP? >>>
>>> I've always used a third argument of IPPROTO_IP, but as I explore
There appears to be no mention of it in the socket() page in MSDN, but
a protocol argument of zero means unspecified. It is discussed in the
Service Provider Interface section, from
http://msdn.microsoft.com/library/en-us/winsock/winsock/transport_division_of_responsibilities_between_dll_and_service_providers_2.asp
"[...] In the case of the socket function, the Ws2_32.dll finds the
first entry in the set of installed WSAPROTOCOL_INFO structures that
matches the values supplied in the tuple formed by the (address family,
socket type, protocol) parameters. To preserve backward compatibility,
the Ws2_32.dll treats the value of zero for either address family or
socket type as a wildcard value. The value of zero for protocol is not
considered a wildcard value by the Ws2_32.dll unless such behavior is
indicated for a particular protocol by having the
PFL_MATCHES_PROTOCOL_ZERO flag set in the WSAPROTOCOL_INFO structure."
I presume the socket() page doesn't mention it as firstly it is for
"backward compatibility", and secondly it need well not apply to
families other that AF_INET.
BTW, [Stevens2004] says, "The protocol argument to the socket function
[...], or 0 to select the system's default for the given combination of
family and type."
Note that IPPROTO_IP has the value 0 (see WinSock2.h). I don't think
though that using it as the last argument is benefical to readability.
The PFL_MATCHES_PROTOCOL_ZERO flag isn't exposed in "netsh winsock show
catalog", but it can be seen in the WSAPROTOCOL_INFO output from
WSAEnumProtocols, e.g.
MSAFD Irda [IrDA]
ServiceFlags1: GD GO IFS [20006]
ProviderFlags: MatchesProtoZero [8]
Version: 2
Address Family: 26 Socket Type: 1 Protocol: 1
Security: 0
MSAFD Tcpip [TCP/IP]
ServiceFlags1: GD GO GraceC ExpData IFS [20066]
ProviderFlags: MatchesProtoZero [8]
Version: 2
Address Family: 2 Socket Type: 1 Protocol: 6
Security: 0
MSAFD Tcpip [UDP/IP]
ServiceFlags1: CL MsgO B M IFS [20609]
ProviderFlags: MatchesProtoZero [8]
Version: 2
Address Family: 2 Socket Type: 2 Protocol: 17
Security: 0
[...]
For some reason the provider "MSAFD Tcpip [RAW/IP]" is not returned by
WSAEnumProtocols (it is apparent in the Registry, and in netsh's
output)...
>>> SOCK_RAW I wonder how argument #2 implies #3 and vice versa. Thanks.
I'll maybe come back to this later, I'll just point to
http://msdn.microsoft.com/library/en-us/winsock/winsock/tcp_ip_raw_sockets_2.asp
>> No, but you have to specify IPROTO_UDP as #3 in this case otherwise
>> ( you use IPROTO_TCP as #3 )WSAEPROTONOSUPPORT have to be returned
>> IIRC
> A little addition. You mentioned SOCK_RAW and here exactly you have to
> specify which raw protoloc (TCP or UDP ) you will implement.
>
Sadly Arkady, as often is the case, I don't understand ...
--
Alan J. McFarlane
http://www.alanjmcf.me.uk/
Please follow-up in the newsgroup for the benefit of all.
.
- Follow-Ups:
- Re: socket arguments
- From: Arkady Frenkel
- Re: socket arguments
- References:
- socket arguments
- From: FrankNatoli
- Re: socket arguments
- From: Arkady Frenkel
- Re: socket arguments
- From: Arkady Frenkel
- socket arguments
- Prev by Date: RE: Questions regarding which APIs to use to retrieve network info
- Next by Date: Interpretation of SavedLegacySettings
- Previous by thread: Re: socket arguments
- Next by thread: Re: socket arguments
- Index(es):
Relevant Pages
|