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