本帖最后由 oyljerry 于 2014-12-28 14:54:10 编辑

解决方案 »

  1.   

    请在send返回0时, 使用WSAGetLastError获取错误码, 然后再判断
      

  2.   

    Return Value
    If no error occurs, send returns the total number of bytes sent, which can be less than the number requested to be sent in the len parameter. Otherwise, a value of SOCKET_ERROR is returned, and a specific error code can be retrieved by calling WSAGetLastError.// Send an initial buffer
        iResult = send( ConnectSocket, sendbuf, (int)strlen(sendbuf), 0 );
        if (iResult == SOCKET_ERROR) {
            printf("send() failed with error: %d\n", WSAGetLastError());
            closesocket(ConnectSocket);
            WSACleanup();
            return 1;
        }    printf("Bytes Sent: %d\n", iResult);
      

  3.   

    if((nbytes=recv(new_fd,aa,sizeof(aa),0)==-1))
    长度好像应该是 sizeof(aa)*3 吧
      

  4.   

    send之后调用WSAGetLastError看错误原因
      

  5.   

    查找本机网卡,建议使用CxNetworkAdapterFind
    http://www.cnblogs.com/EdmundDwyane/p/3233438.html
    查找本机IP,建议使用CxLocalHostIPAddrFind
    http://www.cnblogs.com/EdmundDwyane/p/3200494.html
    网络通信,建议使用CxClientSocket/CxServerSocket/CxUdpSocket
    http://www.cnblogs.com/EdmundDwyane/p/3248297.htmlhttp://www.cnblogs.com/EdmundDwyane/p/3278641.htmlhttp://www.cnblogs.com/EdmundDwyane/p/3218838.html