aboutsummaryrefslogtreecommitdiff
path: root/src/wsocket.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-x[-rw-r--r--]src/wsocket.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/wsocket.c b/src/wsocket.c
index 8ecb0fc..6cb1e41 100644..100755
--- a/src/wsocket.c
+++ b/src/wsocket.c
@@ -5,6 +5,8 @@
5* The penalty of calling select to avoid busy-wait is only paid when 5* The penalty of calling select to avoid busy-wait is only paid when
6* the I/O call fail in the first place. 6* the I/O call fail in the first place.
7\*=========================================================================*/ 7\*=========================================================================*/
8#include "luasocket.h"
9
8#include <string.h> 10#include <string.h>
9 11
10#include "socket.h" 12#include "socket.h"
@@ -131,11 +133,11 @@ int socket_connect(p_socket ps, SA *addr, socklen_t len, p_timeout tm) {
131 /* we wait until something happens */ 133 /* we wait until something happens */
132 err = socket_waitfd(ps, WAITFD_C, tm); 134 err = socket_waitfd(ps, WAITFD_C, tm);
133 if (err == IO_CLOSED) { 135 if (err == IO_CLOSED) {
134 int len = sizeof(err); 136 int elen = sizeof(err);
135 /* give windows time to set the error (yes, disgusting) */ 137 /* give windows time to set the error (yes, disgusting) */
136 Sleep(10); 138 Sleep(10);
137 /* find out why we failed */ 139 /* find out why we failed */
138 getsockopt(*ps, SOL_SOCKET, SO_ERROR, (char *)&err, &len); 140 getsockopt(*ps, SOL_SOCKET, SO_ERROR, (char *)&err, &elen);
139 /* we KNOW there was an error. if 'why' is 0, we will return 141 /* we KNOW there was an error. if 'why' is 0, we will return
140 * "unknown error", but it's not really our fault */ 142 * "unknown error", but it's not really our fault */
141 return err > 0? err: IO_UNKNOWN; 143 return err > 0? err: IO_UNKNOWN;
@@ -358,7 +360,7 @@ const char *socket_ioerror(p_socket ps, int err) {
358static const char *wstrerror(int err) { 360static const char *wstrerror(int err) {
359 switch (err) { 361 switch (err) {
360 case WSAEINTR: return "Interrupted function call"; 362 case WSAEINTR: return "Interrupted function call";
361 case WSAEACCES: return PIE_ACCESS; // "Permission denied"; 363 case WSAEACCES: return PIE_ACCESS; /* "Permission denied"; */
362 case WSAEFAULT: return "Bad address"; 364 case WSAEFAULT: return "Bad address";
363 case WSAEINVAL: return "Invalid argument"; 365 case WSAEINVAL: return "Invalid argument";
364 case WSAEMFILE: return "Too many open files"; 366 case WSAEMFILE: return "Too many open files";
@@ -371,23 +373,23 @@ static const char *wstrerror(int err) {
371 case WSAEPROTOTYPE: return "Protocol wrong type for socket"; 373 case WSAEPROTOTYPE: return "Protocol wrong type for socket";
372 case WSAENOPROTOOPT: return "Bad protocol option"; 374 case WSAENOPROTOOPT: return "Bad protocol option";
373 case WSAEPROTONOSUPPORT: return "Protocol not supported"; 375 case WSAEPROTONOSUPPORT: return "Protocol not supported";
374 case WSAESOCKTNOSUPPORT: return PIE_SOCKTYPE; // "Socket type not supported"; 376 case WSAESOCKTNOSUPPORT: return PIE_SOCKTYPE; /* "Socket type not supported"; */
375 case WSAEOPNOTSUPP: return "Operation not supported"; 377 case WSAEOPNOTSUPP: return "Operation not supported";
376 case WSAEPFNOSUPPORT: return "Protocol family not supported"; 378 case WSAEPFNOSUPPORT: return "Protocol family not supported";
377 case WSAEAFNOSUPPORT: return PIE_FAMILY; // "Address family not supported by protocol family"; 379 case WSAEAFNOSUPPORT: return PIE_FAMILY; /* "Address family not supported by protocol family"; */
378 case WSAEADDRINUSE: return PIE_ADDRINUSE; // "Address already in use"; 380 case WSAEADDRINUSE: return PIE_ADDRINUSE; /* "Address already in use"; */
379 case WSAEADDRNOTAVAIL: return "Cannot assign requested address"; 381 case WSAEADDRNOTAVAIL: return "Cannot assign requested address";
380 case WSAENETDOWN: return "Network is down"; 382 case WSAENETDOWN: return "Network is down";
381 case WSAENETUNREACH: return "Network is unreachable"; 383 case WSAENETUNREACH: return "Network is unreachable";
382 case WSAENETRESET: return "Network dropped connection on reset"; 384 case WSAENETRESET: return "Network dropped connection on reset";
383 case WSAECONNABORTED: return "Software caused connection abort"; 385 case WSAECONNABORTED: return "Software caused connection abort";
384 case WSAECONNRESET: return PIE_CONNRESET; // "Connection reset by peer"; 386 case WSAECONNRESET: return PIE_CONNRESET; /* "Connection reset by peer"; */
385 case WSAENOBUFS: return "No buffer space available"; 387 case WSAENOBUFS: return "No buffer space available";
386 case WSAEISCONN: return PIE_ISCONN; // "Socket is already connected"; 388 case WSAEISCONN: return PIE_ISCONN; /* "Socket is already connected"; */
387 case WSAENOTCONN: return "Socket is not connected"; 389 case WSAENOTCONN: return "Socket is not connected";
388 case WSAESHUTDOWN: return "Cannot send after socket shutdown"; 390 case WSAESHUTDOWN: return "Cannot send after socket shutdown";
389 case WSAETIMEDOUT: return PIE_TIMEDOUT; // "Connection timed out"; 391 case WSAETIMEDOUT: return PIE_TIMEDOUT; /* "Connection timed out"; */
390 case WSAECONNREFUSED: return PIE_CONNREFUSED; // "Connection refused"; 392 case WSAECONNREFUSED: return PIE_CONNREFUSED; /* "Connection refused"; */
391 case WSAEHOSTDOWN: return "Host is down"; 393 case WSAEHOSTDOWN: return "Host is down";
392 case WSAEHOSTUNREACH: return "No route to host"; 394 case WSAEHOSTUNREACH: return "No route to host";
393 case WSAEPROCLIM: return "Too many processes"; 395 case WSAEPROCLIM: return "Too many processes";
@@ -396,9 +398,9 @@ static const char *wstrerror(int err) {
396 case WSANOTINITIALISED: 398 case WSANOTINITIALISED:
397 return "Successful WSAStartup not yet performed"; 399 return "Successful WSAStartup not yet performed";
398 case WSAEDISCON: return "Graceful shutdown in progress"; 400 case WSAEDISCON: return "Graceful shutdown in progress";
399 case WSAHOST_NOT_FOUND: return PIE_HOST_NOT_FOUND; // "Host not found"; 401 case WSAHOST_NOT_FOUND: return PIE_HOST_NOT_FOUND; /* "Host not found"; */
400 case WSATRY_AGAIN: return "Nonauthoritative host not found"; 402 case WSATRY_AGAIN: return "Nonauthoritative host not found";
401 case WSANO_RECOVERY: return PIE_FAIL; // "Nonrecoverable name lookup error"; 403 case WSANO_RECOVERY: return PIE_FAIL; /* "Nonrecoverable name lookup error"; */
402 case WSANO_DATA: return "Valid name, no data record of requested type"; 404 case WSANO_DATA: return "Valid name, no data record of requested type";
403 default: return "Unknown error"; 405 default: return "Unknown error";
404 } 406 }
@@ -427,7 +429,6 @@ const char *socket_gaistrerror(int err) {
427#ifdef EAI_SYSTEM 429#ifdef EAI_SYSTEM
428 case EAI_SYSTEM: return strerror(errno); 430 case EAI_SYSTEM: return strerror(errno);
429#endif 431#endif
430 default: return gai_strerror(err); 432 default: return LUA_GAI_STRERROR(err);
431 } 433 }
432} 434}
433