Re: socket arguments



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.


.



Relevant Pages

  • HEADS UP: network stack and socket hackery over the next few weeks
    ... Over the next few weeks, I'll be doing a fairly serious workworking of the socket and protocol reference models, in order to clean up a number of long-standing race conditions and provide infrastructure for significant locking optimizations for several protocols (including TCP). ...
    (freebsd-current)
  • Re: sockets -- basic udp client
    ... print "Received from server: %s" % buf ... default for timeout is no timeout, or block forever, your question: ... a time out on the socket, and you receive no data and the timeout ... of detecting a zero length datagram as transmitted ...
    (comp.lang.python)
  • Re: sosend/soreceive consistency improvements
    ... As part of cleanups, locking, and optimization work, I've been looking at ... protocol could provide substitute implementations. ... There's another side to the pluggability, however -- the socket consumers ... New references to sosend() and soreceiveperiodically ...
    (freebsd-arch)
  • Re: CAsyncSocket on vista
    ... The error you are getting is WSAEAFNOSUPPORT - Address Family Not ... Perhaps when you are setting up your socket you are not initialising all ... WSAEAFNOSUPPORT Address family not supported by protocol family. ... Conversation: CAsyncSocket on vista ...
    (microsoft.public.vc.mfc)
  • Re: Standard way of graphics in Linux
    ... >> that e_shentsize may be zero. ... >> authorization protocol must be present. ... A server that does not implement the protocol the ... Host access might be sufficient for some installations, but others might require cryptographically- secure authentication. ...
    (alt.lang.asm)