home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / netds / winsock / nwlink / testlib / errmsg.c < prev    next >
C/C++ Source or Header  |  1997-10-05  |  5KB  |  96 lines

  1. /****************************************************************************\
  2. *  errmsg.c -- sample program demonstrating NWLink.
  3. *
  4. *       Original code from Micro Computer Systems, Inc.
  5. *       Copyright(c) 1992  All Rights Reserved.
  6. *       Microsoft Developer Support
  7. *       Copyright (c) 1992-1997 Microsoft Corporation
  8. *
  9. *  Demonstrates basic sockets programming with the Windows Sockets API
  10. *  using the NWLink transport.
  11. ****************************************************************************/
  12. #include <windows.h>
  13. #include "externs.h"
  14.  
  15. /*
  16. *   Messages we return if there was no error or we didn't have it
  17. *   in our list.
  18. */
  19.  
  20. char msg_no_error[19] =      "No error occurred!";
  21. char msg_unknown_error[14] = "Unknown error";
  22.  
  23. /*
  24. *   Error structures - Windows error number (from winsock header) and
  25. *   the corresponding description string.
  26. */
  27.  
  28. ERROR_STRUCT errlist[] = {
  29.     {WSAEINTR,           "WSAEINTR - Interrupted"},
  30.     {WSAEBADF,         "WSAEBADF - Bad file number"},                   
  31.     {WSAEFAULT,       "WSAEFAULT - Bad address"},          
  32.     {WSAEINVAL,          "WSAEINVAL - Invalid argument"},          
  33.     {WSAEMFILE,          "WSAEMFILE - Too many open files"},          
  34.  
  35. /*
  36. *    Windows Sockets definitions of regular Berkeley error constants
  37. */
  38.  
  39.     {WSAEWOULDBLOCK,       "WSAEWOULDBLOCK - Socket marked as non-blocking"},
  40.     {WSAEINPROGRESS,     "WSAEINPROGRESS - Blocking call in progress"},
  41.     {WSAEALREADY,        "WSAEALREADY - Command already completed"},
  42.     {WSAENOTSOCK,        "WSAENOTSOCK - Descriptor is not a socket"},
  43.     {WSAEDESTADDRREQ,    "WSAEDESTADDRREQ - Destination address required"},  
  44.     {WSAEMSGSIZE,        "WSAEMSGSIZE - Data size too large"},     
  45.     {WSAEPROTOTYPE,      "WSAEPROTOTYPE - Protocol is of wrong type for this socket"},   
  46.     {WSAENOPROTOOPT,     "WSAENOPROTOOPT - Protocol option not supported for this socket type"},  
  47.     {WSAEPROTONOSUPPORT, "WSAEPROTONOSUPPORT - Protocol is not supported"},
  48.     {WSAESOCKTNOSUPPORT, "WSAESOCKTNOSUPPORT - Socket type not supported by this address family"},
  49.     {WSAEOPNOTSUPP,      "WSAEOPNOTSUPP - Option not supported"},   
  50.     {WSAEPFNOSUPPORT,    "WSAEPFNOSUPPORT - "}, 
  51.     {WSAEAFNOSUPPORT,    "WSAEAFNOSUPPORT - Address family not supported by this protocol"},
  52.     {WSAEADDRINUSE,      "WSAEADDRINUSE - Address is in use"},   
  53.     {WSAEADDRNOTAVAIL,   "WSAEADDRNOTAVAIL - Address not available from local machine"},
  54.     {WSAENETDOWN,        "WSAENETDOWN - Network subsystem is down"},     
  55.     {WSAENETUNREACH,     "WSAENETUNREACH - Network cannot be reached"},  
  56.     {WSAENETRESET,       "WSAENETRESET - Connection has been dropped"},    
  57.     {WSAECONNABORTED,    "WSAECONNABORTED - "}, 
  58.     {WSAECONNRESET,      "WSAECONNRESET - "},   
  59.     {WSAENOBUFS,         "WSAENOBUFS - No buffer space available"},      
  60.     {WSAEISCONN,         "WSAEISCONN - Socket is already connected"},      
  61.     {WSAENOTCONN,        "WSAENOTCONN - Socket is not connected"},     
  62.     {WSAESHUTDOWN,       "WSAESHUTDOWN - Socket has been shut down"},    
  63.     {WSAETOOMANYREFS,    "WSAETOOMANYREFS - "}, 
  64.     {WSAETIMEDOUT,       "WSAETIMEDOUT - Command timed out"},    
  65.     {WSAECONNREFUSED,    "WSAECONNREFUSED - Connection refused"}, 
  66.     {WSAELOOP,           "WSAELOOP - "},        
  67.     {WSAENAMETOOLONG,    "WSAENAMETOOLONG - "}, 
  68.     {WSAEHOSTDOWN,       "WSAEHOSTDOWN - "},    
  69.     {WSAEHOSTUNREACH,    "WSAEHOSTUNREACH - "}, 
  70.     {WSAENOTEMPTY,       "WSAENOTEMPTY - "},    
  71.     {WSAEPROCLIM,        "WSAEPROCLIM - "},     
  72.     {WSAEUSERS,          "WSAEUSERS - "},       
  73.     {WSAEDQUOT,          "WSAEDQUOT - "},       
  74.     {WSAESTALE,          "WSAESTALE - "},       
  75.     {WSAEREMOTE,         "WSAEREMOTE - "},      
  76.                         
  77. /*
  78. *    Extended Windows Sockets error constant definitions
  79. */
  80.  
  81.     {WSASYSNOTREADY,     "WSASYSNOTREADY - Network subsystem not ready"},  
  82.     {WSAVERNOTSUPPORTED, "WSAVERNOTSUPPORTED - Version not supported"},
  83.     {WSANOTINITIALISED,  "WSANOTINITIALISED - WSAStartup() has not been successfully called"},
  84.  
  85. /*
  86. *    Other error constants.
  87. */
  88.  
  89.     {WSAHOST_NOT_FOUND,  "WSAHOST_NOT_FOUND - Host not found"},
  90.     {WSATRY_AGAIN,       "WSATRY_AGAIN - Host not found or SERVERFAIL"},
  91.     {WSANO_RECOVERY,     "WSANO_RECOVERY - Non-recoverable error"},
  92.     {WSANO_DATA,         "WSANO_DATA - (or WSANO_ADDRESS) - No data record of requested type"},
  93.     {-1,         NULL}
  94. };
  95.