1*657871a7Schristos /* $NetBSD: print-winsock-errors.c,v 1.1.1.1 2021/04/07 02:43:15 christos Exp $ */ 2*657871a7Schristos #include <winsock2.h> 3*657871a7Schristos #include <windows.h> 4*657871a7Schristos 5*657871a7Schristos #include <stdlib.h> 6*657871a7Schristos #include <stdio.h> 7*657871a7Schristos 8*657871a7Schristos #include "event2/event.h" 9*657871a7Schristos #include "event2/util.h" 10*657871a7Schristos #include "event2/thread.h" 11*657871a7Schristos 12*657871a7Schristos #define E(x) printf (#x " -> \"%s\"\n", evutil_socket_error_to_string (x)); 13*657871a7Schristos main(int argc,char ** argv)14*657871a7Schristosint main (int argc, char **argv) 15*657871a7Schristos { 16*657871a7Schristos int i, j; 17*657871a7Schristos const char *s1, *s2; 18*657871a7Schristos 19*657871a7Schristos #ifdef EVTHREAD_USE_WINDOWS_THREADS_IMPLEMENTED 20*657871a7Schristos evthread_use_windows_threads (); 21*657871a7Schristos #endif 22*657871a7Schristos 23*657871a7Schristos s1 = evutil_socket_error_to_string (WSAEINTR); 24*657871a7Schristos 25*657871a7Schristos for (i = 0; i < 3; i++) { 26*657871a7Schristos printf ("\niteration %d:\n\n", i); 27*657871a7Schristos E(WSAEINTR); 28*657871a7Schristos E(WSAEACCES); 29*657871a7Schristos E(WSAEFAULT); 30*657871a7Schristos E(WSAEINVAL); 31*657871a7Schristos E(WSAEMFILE); 32*657871a7Schristos E(WSAEWOULDBLOCK); 33*657871a7Schristos E(WSAEINPROGRESS); 34*657871a7Schristos E(WSAEALREADY); 35*657871a7Schristos E(WSAENOTSOCK); 36*657871a7Schristos E(WSAEDESTADDRREQ); 37*657871a7Schristos E(WSAEMSGSIZE); 38*657871a7Schristos E(WSAEPROTOTYPE); 39*657871a7Schristos E(WSAENOPROTOOPT); 40*657871a7Schristos E(WSAEPROTONOSUPPORT); 41*657871a7Schristos E(WSAESOCKTNOSUPPORT); 42*657871a7Schristos E(WSAEOPNOTSUPP); 43*657871a7Schristos E(WSAEPFNOSUPPORT); 44*657871a7Schristos E(WSAEAFNOSUPPORT); 45*657871a7Schristos E(WSAEADDRINUSE); 46*657871a7Schristos E(WSAEADDRNOTAVAIL); 47*657871a7Schristos E(WSAENETDOWN); 48*657871a7Schristos E(WSAENETUNREACH); 49*657871a7Schristos E(WSAENETRESET); 50*657871a7Schristos E(WSAECONNABORTED); 51*657871a7Schristos E(WSAECONNRESET); 52*657871a7Schristos E(WSAENOBUFS); 53*657871a7Schristos E(WSAEISCONN); 54*657871a7Schristos E(WSAENOTCONN); 55*657871a7Schristos E(WSAESHUTDOWN); 56*657871a7Schristos E(WSAETIMEDOUT); 57*657871a7Schristos E(WSAECONNREFUSED); 58*657871a7Schristos E(WSAEHOSTDOWN); 59*657871a7Schristos E(WSAEHOSTUNREACH); 60*657871a7Schristos E(WSAEPROCLIM); 61*657871a7Schristos E(WSASYSNOTREADY); 62*657871a7Schristos E(WSAVERNOTSUPPORTED); 63*657871a7Schristos E(WSANOTINITIALISED); 64*657871a7Schristos E(WSAEDISCON); 65*657871a7Schristos E(WSATYPE_NOT_FOUND); 66*657871a7Schristos E(WSAHOST_NOT_FOUND); 67*657871a7Schristos E(WSATRY_AGAIN); 68*657871a7Schristos E(WSANO_RECOVERY); 69*657871a7Schristos E(WSANO_DATA); 70*657871a7Schristos E(0xdeadbeef); /* test the case where no message is available */ 71*657871a7Schristos 72*657871a7Schristos /* fill up the hash table a bit to make sure it grows properly */ 73*657871a7Schristos for (j = 0; j < 50; j++) { 74*657871a7Schristos int err; 75*657871a7Schristos evutil_secure_rng_get_bytes(&err, sizeof(err)); 76*657871a7Schristos evutil_socket_error_to_string(err); 77*657871a7Schristos } 78*657871a7Schristos } 79*657871a7Schristos 80*657871a7Schristos s2 = evutil_socket_error_to_string (WSAEINTR); 81*657871a7Schristos if (s1 != s2) 82*657871a7Schristos printf ("caching failed!\n"); 83*657871a7Schristos 84*657871a7Schristos libevent_global_shutdown (); 85*657871a7Schristos 86*657871a7Schristos return EXIT_SUCCESS; 87*657871a7Schristos } 88