inet: return more useful errors
This commit is contained in:
parent
7893d9ece2
commit
a984607f28
@ -175,7 +175,8 @@ int inet_meth_getpeername(lua_State *L, p_socket ps)
|
|||||||
|
|
||||||
if (getpeername(*ps, p, &peer_len) < 0) {
|
if (getpeername(*ps, p, &peer_len) < 0) {
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
lua_pushstring(L, "getpeername failed");
|
lua_pushfstring(L, "getpeername failed (%d): %s", errno,
|
||||||
|
strerror(errno));
|
||||||
} else {
|
} else {
|
||||||
char ipaddr[INET6_ADDRSTRLEN] = "";
|
char ipaddr[INET6_ADDRSTRLEN] = "";
|
||||||
unsigned short port = 0;
|
unsigned short port = 0;
|
||||||
@ -193,7 +194,7 @@ int inet_meth_getpeername(lua_State *L, p_socket ps)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
lua_pushstring(L, "Unknown address family");
|
lua_pushfstring(L, "Unknown address family %d", p->sa_family);
|
||||||
return 2;
|
return 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user