#include <Winsock2.h>
#include <stdio.h>
int main(){
DWORD dwBufferLength = 1000;
LPWSAPROTOCOL_INFO lpProtocolBuffer = NULL;
LPDWORD lpdwBufferLength = &dwBufferLength;
WORD   wVer;  
WSADATA   wsaData;  
wVer=MAKEWORD(2,2); 
if ( WSAStartup(wVer,&wsaData) == SOCKET_ERROR)
{
printf("error number :%d\n",WSAGetLastError());
}
if ( WSAEnumProtocols(NULL,lpProtocolBuffer,lpdwBufferLength) == SOCKET_ERROR )
{
printf("error number : %d \n",WSAGetLastError()); //这里报错,
return 1;
}
return 0;}10055:由于系统缓冲区空间不足或列队已满,不能执行套接字上的操作。 
该如何解决呢?
Thanks。

解决方案 »

  1.   

    LPWSAPROTOCOL_INFO lpProtocolBuffer = NULL;
    这个可以为空么?
      

  2.   


    #include <Winsock2.h>
    #include <stdio.h>int main(){
        DWORD    dwBufferLength = 10000; //这里要足够大
        LPWSAPROTOCOL_INFO lpProtocolBuffer = (WSAPROTOCOL_INFO *)malloc(sizeof(WSAPROTOCOL_INFO));
        LPDWORD lpdwBufferLength = &dwBufferLength;
        WORD   wVer;  
        WSADATA   wsaData;  
        wVer=MAKEWORD(2,2); 
        if ( WSAStartup(wVer,&wsaData) == SOCKET_ERROR)
        {
            printf("error number :%d\n",WSAGetLastError());
        }
        if ( WSAEnumProtocols(NULL,lpProtocolBuffer,lpdwBufferLength) == SOCKET_ERROR )
        {
            printf("error number : %d \n",WSAGetLastError()); //这里报错,
            return 1;
        }
        return 0;}这样就行了,
    lpdwBufferLength 要足够大
    [in, out] On input, the count of bytes in the lpProtocolBuffer buffer passed to WSAEnumProtocols. On output, the minimum buffer size that can be passed to WSAEnumProtocols to retrieve all the requested information. This routine has no ability to enumerate over multiple calls; the passed-in buffer must be large enough to hold all entries in order for the routine to succeed