The Windows Sockets WSAEnumProtocols function retrieves information about available transport protocols.
int WSAEnumProtocols (
LPINT lpiProtocols,
LPWSAPROTOCOL_INFO lpProtocolBuffer,
ILPDWORD lpdwBufferLength
);
The WSAEnumProtocols function is used to discover information about the collection of transport protocols and protocol chains installed on the local machine. Since layered protocols are only usable by applications when installed in protocol chains, information on layered protocols is not included in lpProtocolBuffer. The lpiProtocols parameter can be used as a filter to constrain the amount of information provided. Often, lpiProtocols will be supplied as a NULL pointer that will cause the function to return information on all available transport protocols and protocol chains.
A WSAPROTOCOL_INFO structure is provided in the buffer pointed to by lpProtocolBuffer for each requested protocol. If the supplied buffer is not large enough (as indicated by the input value of lpdwBufferLength ), the value pointed to by lpdwBufferLength will be updated to indicate the required buffer size. The application should then obtain a large enough buffer and call this WSAEnumProtocols again.
The order in which the WSAPROTOCOL_INFO structures appear in the buffer coincides with the order in which the protocol entries were registered by the service provider using the WS2_32.DLL, or with any subsequent re-ordering that can have occurred through the Windows Sockets applet or DLL supplied for establishing default TCP/IP providers.
If no error occurs, WSAEnumProtocols returns the number of protocols to be reported. Otherwise, a value of SOCKET_ERROR is returned and a specific error code can be retrieved by calling WSAGetLastError.
WSANOTINITIALISED | A successful WSAStartup must occur before using this function. |
WSAENETDOWN | The network subsystem has failed. |
WSAEINPROGRESS | A blocking Windows Sockets 1.1 call is in progress. |
WSAEINVAL | Indicates that one of the specified parameters was invalid. |
WSAENOBUFS | The buffer length was too small to receive all the relevant WSAPROTOCOL_INFO structures and associated information. Pass in a buffer at least as large as the value returned in lpdwBufferLength. |
WSAEFAULT | One or more of the lpiProtocols, lpProtocolBuffer, or lpdwBufferLength arguments are not a valid part of the user address space. |
Windows NT: Yes
Windows: Yes
Windows CE: Unsupported.
Header: Declared in winsock2.h.
Import Library: Link with ws2_32.lib.