+char *winsock_error_string(int error) {
+ switch (error) {
+ case WSAEACCES: return "Network error: Permission denied";
+ case WSAEADDRINUSE: return "Network error: Address already in use";
+ case WSAEADDRNOTAVAIL: return "Network error: Cannot assign requested address";
+ case WSAEAFNOSUPPORT: return "Network error: Address family not supported by protocol family";
+ case WSAEALREADY: return "Network error: Operation already in progress";
+ case WSAECONNABORTED: return "Network error: Software caused connection abort";
+ case WSAECONNREFUSED: return "Network error: Connection refused";
+ case WSAECONNRESET: return "Network error: Connection reset by peer";
+ case WSAEDESTADDRREQ: return "Network error: Destination address required";
+ case WSAEFAULT: return "Network error: Bad address";
+ case WSAEHOSTDOWN: return "Network error: Host is down";
+ case WSAEHOSTUNREACH: return "Network error: No route to host";
+ case WSAEINPROGRESS: return "Network error: Operation now in progress";
+ case WSAEINTR: return "Network error: Interrupted function call";
+ case WSAEINVAL: return "Network error: Invalid argument";
+ case WSAEISCONN: return "Network error: Socket is already connected";
+ case WSAEMFILE: return "Network error: Too many open files";
+ case WSAEMSGSIZE: return "Network error: Message too long";
+ case WSAENETDOWN: return "Network error: Network is down";
+ case WSAENETRESET: return "Network error: Network dropped connection on reset";
+ case WSAENETUNREACH: return "Network error: Network is unreachable";
+ case WSAENOBUFS: return "Network error: No buffer space available";
+ case WSAENOPROTOOPT: return "Network error: Bad protocol option";
+ case WSAENOTCONN: return "Network error: Socket is not connected";
+ case WSAENOTSOCK: return "Network error: Socket operation on non-socket";
+ case WSAEOPNOTSUPP: return "Network error: Operation not supported";
+ case WSAEPFNOSUPPORT: return "Network error: Protocol family not supported";
+ case WSAEPROCLIM: return "Network error: Too many processes";
+ case WSAEPROTONOSUPPORT: return "Network error: Protocol not supported";
+ case WSAEPROTOTYPE: return "Network error: Protocol wrong type for socket";
+ case WSAESHUTDOWN: return "Network error: Cannot send after socket shutdown";
+ case WSAESOCKTNOSUPPORT: return "Network error: Socket type not supported";
+ case WSAETIMEDOUT: return "Network error: Connection timed out";
+ case WSAEWOULDBLOCK: return "Network error: Resource temporarily unavailable";
+ case WSAEDISCON: return "Network error: Graceful shutdown in progress";
+ default: return "Unknown network error";
+ }
+}
+
+SockAddr sk_namelookup(char *host, char **canonicalname)
+{