我做的程序,调试没有问题,但就是不执行结果,怎么解决啊?我做的是屏幕截图,就是出现不了屏幕图像。
我看到好多说 用  WSAGetLastError  检测的,怎么用的,怎么才能知道错误呢?谢谢了

解决方案 »

  1.   

    WSAGetLastError是获取Socket错误的。如果普通API函数调用失败后应该调用GetLastError。
      

  2.   

    我就是想获取socket错误,可是我不知道怎么用?
      

  3.   

    if( 0 > send(...))
    {
      printf("send error:%d\n", WSAGetLastError);
      //错误处理
    }
      

  4.   

    判断函数返回值,如果失败了离开调用WSAGetLastError
      

  5.   

    但就是不执行可能是什么原因呢
    //如果是多线程的,可能涉及线程同步问题。在socket函数失败之后,调用WSAGetLastError判断具体错误
      

  6.   

    //在socket函数失败之后,调用WSAGetLastError判断具体错误//应该怎么调用呢?我发现我真的什么都不会,谢谢大家的帮助了,我真的很想努力的解决问题
      

  7.   

    if(socket失败)
    {
      DWORD dwError = WSAGetLastError();
    }
      

  8.   

    http://msdn.microsoft.com/en-us/library/ms741580(VS.85).aspx最好的函数手册 MSDN
    在线的 msdn.microsoft.com/en-us
      

  9.   

    switch (WSAGetLastError())
    {
    case WSANOTINITIALISED:
    TRACE("A successful WSAStartup call must occur before using this function. ");
    break;
    case WSAENETDOWN:
    TRACE("The network subsystem has failed. ");
    break;
    case WSAEACCES:
    TRACE("The requested address is a broadcast address, but the appropriate flag was not set. Call setsockopt with the SO_BROADCAST parameter to allow the use of the broadcast address. ");
    break;
    case WSAEINVAL:
    TRACE("An unknown flag was specified, or MSG_OOB was specified for a socket with SO_OOBINLINE enabled. ");
    break;
    case WSAEINTR:
    TRACE("A blocking Windows Sockets 1.1 call was canceled through WSACancelBlockingCall. ");
    break;
    case WSAEINPROGRESS:
    TRACE("A blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function. ");
    break;
    case WSAEFAULT:
    TRACE("The buf or to parameters are not part of the user address space, or the tolen parameter is too small. ");
    break;
    case WSAENETRESET:
    TRACE("The connection has been broken due to keep-alive activity detecting a failure while the operation was in progress. ");
    break;
    case WSAENOBUFS:
    TRACE("No buffer space is available. ");
    break;
    case WSAENOTCONN:
    TRACE("The socket is not connected (connection-oriented sockets only). ");
    break;
    case WSAENOTSOCK:
    TRACE("The descriptor is not a socket. ");
    break;
    case WSAEOPNOTSUPP:
    TRACE("MSG_OOB was specified, but the socket is not stream-style such as type SOCK_STREAM, OOB data is not supported in the communication domain associated with this socket, or the socket is unidirectional and supports only receive operations. ");
    break;
    case WSAESHUTDOWN:
    TRACE("The socket has been shut down; it is not possible to sendto on a socket after shutdown has been invoked with how set to SD_SEND or SD_BOTH. ");
    break;
    case WSAEWOULDBLOCK:
    TRACE("The socket is ed as nonblocking and the requested operation would block. ");
    break;
    case WSAEMSGSIZE:
    TRACE("The socket is message oriented, and the message is larger than the maximum supported by the underlying transport. ");
    break;
    case WSAEHOSTUNREACH:
    TRACE("The remote host cannot be reached from this host at this time. ");
    break;
    case WSAECONNABORTED:
    TRACE("The virtual circuit was terminated due to a time-out or other failure. The application should close the socket as it is no longer usable. ");
    break;
    case WSAECONNRESET:
    TRACE("The virtual circuit was reset by the remote side executing a hard or abortive close. For UPD sockets, the remote host was unable to deliver a previously sent UDP datagram and responded with a \"Port Unreachable\" ICMP packet. The application should close the socket as it is no longer usable. ");
    break;
    case WSAEADDRNOTAVAIL:
    TRACE("The remote address is not a valid address, for example, ADDR_ANY. ");
    break;
    case WSAEAFNOSUPPORT:
    TRACE("Addresses in the specified family cannot be used with this socket. ");
    break;
    case WSAEDESTADDRREQ:
    TRACE("A destination address is required. ");
    break;
    case WSAENETUNREACH:
    TRACE("The network cannot be reached from this host at this time. ");
    break;
    case WSAETIMEDOUT:
    TRACE("The connection has been dropped, because of a network failure or because the system on the other end went down without notice. ");
    break;
    default:
    TRACE("Unknown socket error. ");
    break;
      

  10.   

    必须在加载winsock后,该函数才起作用