找回密码
 立即注册→加入我们

QQ登录

只需一步,快速开始

搜索
热搜: 下载 VB C 实现 编写
查看: 2976|回复: 2

【MSDN】WSAGetLastError(h_errno)Winsock相关错误代码查询

[复制链接]
发表于 2014-5-20 18:41:31 | 显示全部楼层 |阅读模式

欢迎访问技术宅的结界,请注册或者登录吧。

您需要 登录 才可以下载或查看,没有账号?立即注册→加入我们

×
搬运自MSDN Library - October 2001。
找到这页信息的方法是在MSDN打开后的界面找到“索引(N)”选项卡,然后输入关键词“Winsock API [Winsock]”(注意去掉引号),找到“Error Codes in the API
”,双击打开即可。
如下图所示。
20140520181819.png
这样就能找到了。当然我会把MSDN上的这些内容搬运到这里的。如果懒得自己打开MSDN看的话请回帖查看我搬运的内容。
游客,如果您要查看本帖隐藏内容请回复
回复

使用道具 举报

 楼主| 发表于 2014-6-2 21:01:42 | 显示全部楼层
以下是将h_errno翻译成字符串的函数。配合printf、sprintf、fprintf可以很好地打印错误信息。
  1. char*h_error_String()
  2. {
  3.     switch(h_errno)
  4.     {
  5.     case WSAEACCES:
  6.         return"WSAEACCES";
  7.     case WSAEADDRINUSE:
  8.         return"WSAEADDRINUSE";
  9.     case WSAEADDRNOTAVAIL:
  10.         return"WSAEADDRNOTAVAIL";
  11.     case WSAEAFNOSUPPORT:
  12.         return"WSAEAFNOSUPPORT";
  13.     case WSAEALREADY:
  14.         return"WSAEALREADY";
  15.     case WSAECONNABORTED:
  16.         return"WSAECONNABORTED";
  17.     case WSAECONNREFUSED:
  18.         return"WSAECONNREFUSED";
  19.     case WSAECONNRESET:
  20.         return"WSAECONNRESET";
  21.     case WSAEDESTADDRREQ:
  22.         return"WSAEDESTADDRREQ";
  23.     case WSAEFAULT:
  24.         return"WSAEFAULT";
  25.     case WSAEHOSTDOWN:
  26.         return"WSAEHOSTDOWN";
  27.     case WSAEHOSTUNREACH:
  28.         return"WSAEHOSTUNREACH";
  29.     case WSAEINPROGRESS:
  30.         return"WSAEINPROGRESS";
  31.     case WSAEINTR:
  32.         return"WSAEINTR";
  33.     case WSAEINVAL:
  34.         return"WSAEINVAL";
  35.     case WSAEISCONN:
  36.         return"WSAEISCONN";
  37.     case WSAEMFILE:
  38.         return"WSAEMFILE";
  39.     case WSAEMSGSIZE:
  40.         return"WSAEMSGSIZE";
  41.     case WSAENETDOWN:
  42.         return"WSAENETDOWN";
  43.     case WSAENETRESET:
  44.         return"WSAENETRESET";
  45.     case WSAENETUNREACH:
  46.         return"WSAENETUNREACH";
  47.     case WSAENOBUFS:
  48.         return"WSAENOBUFS";
  49.     case WSAENOPROTOOPT:
  50.         return"WSAENOPROTOOPT";
  51.     case WSAENOTCONN:
  52.         return"WSAENOTCONN";
  53.     case WSAENOTSOCK:
  54.         return"WSAENOTSOCK";
  55.     case WSAEOPNOTSUPP:
  56.         return"WSAEOPNOTSUPP";
  57.     case WSAEPFNOSUPPORT:
  58.         return"WSAEPFNOSUPPORT";
  59.     case WSAEPROCLIM:
  60.         return"WSAEPROCLIM";
  61.     case WSAEPROTONOSUPPORT:
  62.         return"WSAEPROTONOSUPPORT";
  63.     case WSAEPROTOTYPE:
  64.         return"WSAEPROTOTYPE";
  65.     case WSAESHUTDOWN:
  66.         return"WSAESHUTDOWN";
  67.     case WSAESOCKTNOSUPPORT:
  68.         return"WSAESOCKTNOSUPPORT";
  69.     case WSAETIMEDOUT:
  70.         return"WSAETIMEDOUT";
  71.     case WSATYPE_NOT_FOUND:
  72.         return"WSATYPE_NOT_FOUND";
  73.     case WSAEWOULDBLOCK:
  74.         return"WSAEWOULDBLOCK";
  75.     case WSAHOST_NOT_FOUND:
  76.         return"WSAHOST_NOT_FOUND";
  77.     case WSA_INVALID_HANDLE:
  78.         return"WSA_INVALID_HANDLE";
  79.     case WSA_INVALID_PARAMETER:
  80.         return"WSA_INVALID_PARAMETER";
  81.     case WSAEINVALIDPROCTABLE:
  82.         return"WSAEINVALIDPROCTABLE";
  83.     case WSAEINVALIDPROVIDER:
  84.         return"WSAEINVALIDPROVIDER";
  85.     case WSA_IO_INCOMPLETE:
  86.         return"WSA_IO_INCOMPLETE";
  87.     case WSA_IO_PENDING:
  88.         return"WSA_IO_PENDING";
  89.     case WSA_NOT_ENOUGH_MEMORY:
  90.         return"WSA_NOT_ENOUGH_MEMORY";
  91.     case WSANOTINITIALISED:
  92.         return"WSANOTINITIALISED";
  93.     case WSANO_DATA:
  94.         return"WSANO_DATA";
  95.     case WSANO_RECOVERY:
  96.         return"WSANO_RECOVERY";
  97.     case WSAEPROVIDERFAILEDINIT:
  98.         return"WSAEPROVIDERFAILEDINIT";
  99.     case WSASYSCALLFAILURE:
  100.         return"WSASYSCALLFAILURE";
  101.     case WSASYSNOTREADY:
  102.         return"WSASYSNOTREADY";
  103.     case WSATRY_AGAIN:
  104.         return"WSATRY_AGAIN";
  105.     case WSAVERNOTSUPPORTED:
  106.         return"WSAVERNOTSUPPORTED";
  107.     case WSAEDISCON:
  108.         return"WSAEDISCON";
  109.     case WSA_OPERATION_ABORTED:
  110.         return"WSA_OPERATION_ABORTED";
  111.     default:
  112.         return"";
  113.     }
  114. }
复制代码

回复 赞! 靠!

使用道具 举报

发表于 2024-6-11 15:44:23 | 显示全部楼层
感谢感谢
回复

使用道具 举报

本版积分规则

QQ|Archiver|小黑屋|技术宅的结界 ( 滇ICP备16008837号 )|网站地图

GMT+8, 2024-12-22 00:46 , Processed in 0.037226 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表