WSAGetLastError()可以检查出错原因 错误名称与解释如下: WSANOTINITIALISED: A successful WSAStartup must occur before using this function. WSAENETDOWN: The network subsystem has failed. WSAEACCES: 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. WSAEINTR: A blocking Windows Sockets 1.1 call was canceled through WSACancelBlockingCall. WSAEINPROGRESS: A blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function. WSAEFAULT: The buf parameter is not completely contained in a valid part of the user address space. WSAENETRESET: The connection has been broken due to the "keep-alive" activity detecting a failure while the operation was in progress. WSAENOBUFS: No buffer space is available. WSAENOTCONN: The socket is not connected. WSAENOTSOCK: The descriptor is not a socket. WSAEOPNOTSUPP: MSG_OOB was specified, but the socket is not stream-style such as type SOCK_STREAM, out-of-band data is not supported in the communication domain associated with this socket, or the socket is unidirectional and supports only receive operations. WSAESHUTDOWN :The socket has been shut down; it is not possible to send on a socket after shutdown has been invoked with how set to SD_SEND or SD_BOTH. WSAEWOULDBLOCK: The socket is ed as nonblocking and the requested operation would block. WSAEMSGSIZE: The socket is message oriented, and the message is larger than the maximum supported by the underlying transport. WSAEHOSTUNREACH: The remote host cannot be reached from this host at this time. WSAEINVAL: The socket has not been bound with bind, or an unknown flag was specified, or MSG_OOB was specified for a socket with SO_OOBINLINE enabled. WSAECONNABORTED: 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. WSAECONNRESET: 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. WSAETIMEDOUT: The connection has been dropped, because of a network failure or because the system on the other end went down without notice.
2. ?
3. ?
错误名称与解释如下:
WSANOTINITIALISED: A successful WSAStartup must occur before using this function.
WSAENETDOWN: The network subsystem has failed.
WSAEACCES: 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.
WSAEINTR: A blocking Windows Sockets 1.1 call was canceled through WSACancelBlockingCall.
WSAEINPROGRESS: A blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function.
WSAEFAULT: The buf parameter is not completely contained in a valid part of the user address space.
WSAENETRESET: The connection has been broken due to the "keep-alive" activity detecting a failure while the operation was in progress.
WSAENOBUFS: No buffer space is available.
WSAENOTCONN: The socket is not connected.
WSAENOTSOCK: The descriptor is not a socket.
WSAEOPNOTSUPP: MSG_OOB was specified, but the socket is not stream-style such as type SOCK_STREAM, out-of-band data is not supported in the communication domain associated with this socket, or the socket is unidirectional and supports only receive operations.
WSAESHUTDOWN :The socket has been shut down; it is not possible to send on a socket after shutdown has been invoked with how set to SD_SEND or SD_BOTH.
WSAEWOULDBLOCK: The socket is ed as nonblocking and the requested operation would block.
WSAEMSGSIZE: The socket is message oriented, and the message is larger than the maximum supported by the underlying transport.
WSAEHOSTUNREACH: The remote host cannot be reached from this host at this time.
WSAEINVAL: The socket has not been bound with bind, or an unknown flag was specified, or MSG_OOB was specified for a socket with SO_OOBINLINE enabled.
WSAECONNABORTED: 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.
WSAECONNRESET: 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.
WSAETIMEDOUT: The connection has been dropped, because of a network failure or because the system on the other end went down without notice.