Return Values If no error occurs, send returns the total number of bytes sent, which can be less than the number indicated by len for nonblocking sockets. Otherwise, a value of SOCKET_ERROR is returned, and a specific error code can be retrieved by calling WSAGetLastError. 你WSAGetLastError一下看看错误码然后通过error lookup看看是什么错误
1、send 不确保发送出去全部的数据,函数返回实际发送的数据的字节数;所以,程序要检查返回值来发送剩余的数据(用一个循环就可以了);
2、争取执行关闭过程,这个在 MSDN 上有详细的说明,参考 shutdown 的说明会得到这方面的连接。希望对你有所启发哦。
If no error occurs, send returns the total number of bytes sent, which can be less than the number indicated by len for nonblocking sockets. Otherwise, a value of SOCKET_ERROR is returned, and a specific error code can be retrieved by calling WSAGetLastError.
你WSAGetLastError一下看看错误码然后通过error lookup看看是什么错误