I'm revisiting winsock after all these years with fresh eyes and can't seem to understand why SOCK_STREAM and IPPROTO_TCP are both necessary to specify in the pHints parameter of getaddrinfo:
INT WSAAPI getaddrinfo(
[in, optional] PCSTR pNodeName,
[in, optional] PCSTR pServiceName,
[in, optional] const ADDRINFOA *pHints,
[out] PADDRINFOA *ppResult
);
Reading through MSDN's documentation on addrinfo also doesn't seem to shed much light.
In that article is a table with possible SOCK_ type definitions and it has this to say in the meaning of SOCK_STREAM.
Provides sequenced, reliable, two-way, connection-based byte streams with an OOB data transmission mechanism. Uses the Transmission Control Protocol (TCP) for the Internet address family (AF_INET or AF_INET6). If the ai_family member is AF_IRDA, then SOCK_STREAM is the only supported socket type.
What's the purpose of separating socket type and protocol if it seems one necessitates the other, and from what I can tell, aren't interchangeable among other protocols and socket types?
Is this for legacy purposes? Something vestigial in nature? Thanks.
EDIT: To further my point addrinfo also defines IPPROTO_TCP in this manner.
The Transmission Control Protocol (TCP). This is a possible value when the ai_family member is AF_INET or AF_INET6 and the ai_socktype member is SOCK_STREAM.
EDIT2: After some nudging in the right direction thanks to comments it would seem there are a handful of protocols that utilize stream sockets: RSVP, RDP, X.25, TCP, and SCTP.
But, from what I have been able to read into thus far, a stream socket and TCP itself both guarantee the same connection characteristics if you will. Both are reliable, have error checking, support full-duplex communication, etc. The definitions seem indistinguishable to me. It makes me question whether or not TCP is in it's most fundamental form just a vanilla protocol stealing the spotlight from sock stream.
I seriously can't seem to grasp the difference between the two.