mirror of
https://github.com/lunarmodules/luasocket.git
synced 2025-07-19 15:29:45 +02:00
Compare commits
2 Commits
527b6cc87f
...
hjelmeland
Author | SHA1 | Date | |
---|---|---|---|
5c4fc93d5f | |||
ccef3bc4e2 |
@ -290,7 +290,7 @@ int inet_meth_getsockname(lua_State *L, p_socket ps, int family)
|
||||
return 2;
|
||||
}
|
||||
lua_pushstring(L, name);
|
||||
lua_pushinteger(L, (int) strtol(port, (char **) NULL, 10));
|
||||
lua_pushstring(L, port);
|
||||
switch (family) {
|
||||
case AF_INET: lua_pushliteral(L, "inet"); break;
|
||||
case AF_INET6: lua_pushliteral(L, "inet6"); break;
|
||||
|
@ -12,7 +12,7 @@
|
||||
#define PIE_CONNREFUSED "connection refused"
|
||||
#define PIE_CONNABORTED "closed"
|
||||
#define PIE_CONNRESET "closed"
|
||||
#define PIE_TIMEDOUT "timeout"
|
||||
#define PIE_TIMEDOUT "connection timeout"
|
||||
#define PIE_AGAIN "temporary failure in name resolution"
|
||||
#define PIE_BADFLAGS "invalid value for ai_flags"
|
||||
#define PIE_BADHINTS "invalid value for hints"
|
||||
|
@ -152,7 +152,7 @@ function _M.parse(url, default)
|
||||
url = string.gsub(url, "^([%w][%w%+%-%.]*)%:",
|
||||
function(s) parsed.scheme = s; return "" end)
|
||||
-- get authority
|
||||
url = string.gsub(url, "^//([^/%?#]*)", function(n)
|
||||
url = string.gsub(url, "^//([^/]*)", function(n)
|
||||
parsed.authority = n
|
||||
return ""
|
||||
end)
|
||||
|
@ -127,19 +127,7 @@ int socket_connect(p_socket ps, SA *addr, socklen_t len, p_timeout tm) {
|
||||
if (connect(*ps, addr, len) == 0) return IO_DONE;
|
||||
/* make sure the system is trying to connect */
|
||||
err = WSAGetLastError();
|
||||
|
||||
if (err == WSAEISCONN) return IO_DONE; // already connected?
|
||||
|
||||
// hotfix for nonblocking, slow TCP connections not returning instantly
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms737625(v=vs.85).aspx
|
||||
// "Note In order to preserve backward compatibility, this error is reported as WSAEINVAL to Windows Sockets 1.1 applications that link to either Winsock.dll or Wsock32.dll."
|
||||
// The only other valid reason to get WSAINVAL is that: The parameter s is a listening socket. So we hope that doesn't happen here.
|
||||
if (err == WSAEINVAL) {
|
||||
return WSAEALREADY;
|
||||
}
|
||||
|
||||
if (err != WSAEWOULDBLOCK && err != WSAEINPROGRESS) return err;
|
||||
|
||||
/* zero timeout case optimization */
|
||||
if (timeout_iszero(tm)) return IO_TIMEOUT;
|
||||
/* we wait until something happens */
|
||||
@ -274,7 +262,6 @@ int socket_recv(p_socket ps, char *data, size_t count, size_t *got,
|
||||
if (err != WSAEWOULDBLOCK) {
|
||||
if (err != WSAECONNRESET || prev == WSAECONNRESET) return err;
|
||||
prev = err;
|
||||
continue;
|
||||
}
|
||||
if ((err = socket_waitfd(ps, WAITFD_R, tm)) != IO_DONE) return err;
|
||||
}
|
||||
@ -304,7 +291,6 @@ int socket_recvfrom(p_socket ps, char *data, size_t count, size_t *got,
|
||||
if (err != WSAEWOULDBLOCK) {
|
||||
if (err != WSAECONNRESET || prev == WSAECONNRESET) return err;
|
||||
prev = err;
|
||||
continue;
|
||||
}
|
||||
if ((err = socket_waitfd(ps, WAITFD_R, tm)) != IO_DONE) return err;
|
||||
}
|
||||
|
Reference in New Issue
Block a user