#include <iostream> #include <string> #include "Winsock2.h" #include <WS2tcpip.h>…
- User
#include #include #include "Winsock2.h" #include <WS2tcpip.h> #include #pragma comment(lib, "WS2_32.lib")
using namespace std; using namespace std::chrono;
string GetErrorMsgText(int code) { string msgText; switch (code) { case WSAEINTR: msgText = "WSAEINTR: Interrupted function call"; break; case WSAEACCES: msgText = "WSAEACCES: Permission denied"; break; case WSAEFAULT: msgText = "WSAEFAULT: Bad address"; break; case WSAEINVAL: msgText = "WSAEINVAL: Invalid argument"; break; case WSAEMFILE: msgText = "WSAEMFILE: Too many open files"; break; case WSAEWOULDBLOCK: msgText = "WSAEWOULDBLOCK: Resource temporarily unavailable"; break; case WSAEINPROGRESS: msgText = "WSAEINPROGRESS: Operation now in progress"; break; case WSAEALREADY: msgText = "WSAEALREADY: Operation already in progress"; break; case WSAENOTSOCK: msgText = "WSAENOTSOCK: Socket operation on non-socket"; break; case WSAEDESTADDRREQ: msgText = "WSAEDESTADDRREQ: Destination address required"; break; case WSAEMSGSIZE: msgText = "WSAEMSGSIZE: Message too long"; break; case WSAEPROTOTYPE: msgText = "WSAEPROTOTYPE: Protocol wrong type for socket"; break; case WSAENOPROTOOPT: msgText = "WSAENOPROTOOPT: Bad protocol option"; break; case WSAEPROTONOSUPPORT: msgText = "WSAEPROTONOSUPPORT: Protocol not supported"; break; case WSAESOCKTNOSUPPORT: msgText = "WSAESOCKTNOSUPPORT: Socket type not supported"; break; case WSAEOPNOTSUPP: msgText = "WSAEOPNOTSUPP: Operation not supported"; break; case WSAEPFNOSUPPORT: msgText = "WSAEPFNOSUPPORT: Protocol family not supported"; break; case WSAEAFNOSUPPORT: msgText = "WSAEAFNOSUPPORT: Address family not supported by protocol family"; break; case WSAEADDRINUSE: msgText = "WSAEADDRINUSE: Address already in use"; break; case WSAEADDRNOTAVAIL: msgText = "WSAEADDRNOTAVAIL: Cannot assign requested address"; break; case WSAENETDOWN: msgText = "WSAENETDOWN: Network is down"; break; case WSAENETUNREACH: msgText = "WSAENETUNREACH: Network is unreachable"; break; case WSAENETRESET: msgText = "WSAENETRESET: Network dropped connection on reset"; break; case WSAECONNABORTED: msgText = "WSAECONNABORTED: Software caused connection abort"; break; case WSAECONNRESET: msgText = "WSAECONNRESET: Connection reset by peer"; break; case WSAENOBUFS: msgText = "WSAENOBUFS: No buffer space available"; break; case WSAEISCONN: msgText = "WSAEISCONN: Socket is already connected"; break; case WSAENOTCONN: msgText = "WSAENOTCONN: Socket is not connected"; break; case WSAESHUTDOWN: msgText = "WSAESHUTDOWN: Cannot send after socket shutdown"; break; case WSAETIMEDOUT: msgText = "WSAETIMEDOUT: Connection timed out"; break; case WSAECONNREFUSED: msgText = "WSAECONNREFUSED: Connection refused"; break; case WSAEHOSTDOWN: msgText = "WSAEHOSTDOWN: Host is down"; break; case WSAEHOSTUNREACH: msgText = "WSAEHOSTUNREACH: No route to host"; break; case WSASYSCALLFAILURE: msgText = "WSASYSCALLFAILURE: System call failure"; break; default: msgText = ": Unknown error"; break; } return msgText; }
- Assistant