aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Aurich <paul@darkrain42.org>2011-07-03 14:28:22 -0700
committerSam Roberts <vieuxtech@gmail.com>2012-04-11 13:33:34 -0700
commita984607f28d0a802acaf1a16da225234af769baa (patch)
tree7b52e9f4df47153dbdd10130ba1be078164a2479
parent7893d9ece28399092e1a167de9c1e6c05e5721d0 (diff)
downloadluasocket-a984607f28d0a802acaf1a16da225234af769baa.tar.gz
luasocket-a984607f28d0a802acaf1a16da225234af769baa.tar.bz2
luasocket-a984607f28d0a802acaf1a16da225234af769baa.zip
inet: return more useful errors
-rw-r--r--src/inet.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/inet.c b/src/inet.c
index aefad27..571b838 100644
--- a/src/inet.c
+++ b/src/inet.c
@@ -175,7 +175,8 @@ int inet_meth_getpeername(lua_State *L, p_socket ps)
175 175
176 if (getpeername(*ps, p, &peer_len) < 0) { 176 if (getpeername(*ps, p, &peer_len) < 0) {
177 lua_pushnil(L); 177 lua_pushnil(L);
178 lua_pushstring(L, "getpeername failed"); 178 lua_pushfstring(L, "getpeername failed (%d): %s", errno,
179 strerror(errno));
179 } else { 180 } else {
180 char ipaddr[INET6_ADDRSTRLEN] = ""; 181 char ipaddr[INET6_ADDRSTRLEN] = "";
181 unsigned short port = 0; 182 unsigned short port = 0;
@@ -193,7 +194,7 @@ int inet_meth_getpeername(lua_State *L, p_socket ps)
193 break; 194 break;
194 default: 195 default:
195 lua_pushnil(L); 196 lua_pushnil(L);
196 lua_pushstring(L, "Unknown address family"); 197 lua_pushfstring(L, "Unknown address family %d", p->sa_family);
197 return 2; 198 return 2;
198 break; 199 break;
199 } 200 }