Protocol-Specific Information

This section details information relevant to specific network protocols supported by Winsock. Understanding these details is crucial for developing robust and efficient network applications.

TCP/IP Considerations

The Transmission Control Protocol (TCP) and Internet Protocol (IP) suite are the foundational protocols for most network communication on Windows. When working with TCP/IP sockets, consider the following:

Key Winsock Functions for TCP/IP:

Other Protocols

While TCP/IP is dominant, Winsock supports other protocols through different address families and protocol identifiers. These might include:

When using these protocols, ensure that the corresponding protocol drivers are installed and configured correctly on the system. The address family and protocol type passed to the socket() function will dictate the protocol being used.

Important Note on Protocol Selection

The choice of protocol significantly impacts application design. TCP is suitable for applications requiring reliable data transfer (e.g., web browsing, file transfer), while UDP is preferred for speed-sensitive applications where occasional data loss is acceptable (e.g., online gaming, streaming audio/video).

Protocol Information Structures

Winsock provides specific structures to carry protocol-dependent information. For example, when dealing with IP, you'll commonly use structures like sockaddr_in.


struct sockaddr_in {
    short            sin_family;   // AF_INET
    unsigned short   sin_port;     // Port number
    struct in_addr   sin_addr;     // IP address
    char             sin_zero[8];  // Not used
};
            

For IPv6, the sockaddr_in6 structure is used.

Deprecation of Legacy Protocols

Support for protocols other than TCP/IP may be limited or deprecated in newer Windows versions. Always refer to the specific API documentation for compatibility and best practices.