aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2001-06-08 22:36:30 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2001-06-08 22:36:30 +0000
commit4456edcd0b56dd1401b58192b94b8364dab69c02 (patch)
treeb546cee742162968fb0fa1f416c13ce40e623412 /src
parent23dcfabcf1234aba4f2b2ed57a20f56e6e75fc16 (diff)
downloadluasocket-4456edcd0b56dd1401b58192b94b8364dab69c02.tar.gz
luasocket-4456edcd0b56dd1401b58192b94b8364dab69c02.tar.bz2
luasocket-4456edcd0b56dd1401b58192b94b8364dab69c02.zip
udpsocket errors are more verbose
Diffstat (limited to 'src')
-rw-r--r--src/luasocket.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/luasocket.c b/src/luasocket.c
index 5cea287..bd3f473 100644
--- a/src/luasocket.c
+++ b/src/luasocket.c
@@ -1080,7 +1080,8 @@ static int set_option(lua_State *L, p_sock sock)
1080 switch (luaL_findstring(option, optionnames)) { 1080 switch (luaL_findstring(option, optionnames)) {
1081 case 0: { 1081 case 0: {
1082 int bool; 1082 int bool;
1083 if (!lua_isnumber(L, -1)) return 0; 1083 if (!lua_isnumber(L, -1))
1084 lua_error(L, "invalid SO_KEEPALIVE value");
1084 bool = (int) lua_tonumber(L, -1); 1085 bool = (int) lua_tonumber(L, -1);
1085 err = setsockopt(sock->sock, SOL_SOCKET, SO_KEEPALIVE, 1086 err = setsockopt(sock->sock, SOL_SOCKET, SO_KEEPALIVE,
1086 (char *) &bool, sizeof(bool)); 1087 (char *) &bool, sizeof(bool));
@@ -1088,7 +1089,8 @@ static int set_option(lua_State *L, p_sock sock)
1088 } 1089 }
1089 case 1: { 1090 case 1: {
1090 int bool; 1091 int bool;
1091 if (!lua_isnumber(L, -1)) return 0; 1092 if (!lua_isnumber(L, -1))
1093 lua_error(L, "invalid SO_DONTROUTE value");
1092 bool = (int) lua_tonumber(L, -1); 1094 bool = (int) lua_tonumber(L, -1);
1093 err = setsockopt(sock->sock, SOL_SOCKET, SO_DONTROUTE, 1095 err = setsockopt(sock->sock, SOL_SOCKET, SO_DONTROUTE,
1094 (char *) &bool, sizeof(bool)); 1096 (char *) &bool, sizeof(bool));
@@ -1096,7 +1098,8 @@ static int set_option(lua_State *L, p_sock sock)
1096 } 1098 }
1097 case 2: { 1099 case 2: {
1098 int bool; 1100 int bool;
1099 if (!lua_isnumber(L, -1)) return 0; 1101 if (!lua_isnumber(L, -1))
1102 lua_error(L, "invalid SO_BROADCAST value");
1100 bool = (int) lua_tonumber(L, -1); 1103 bool = (int) lua_tonumber(L, -1);
1101 err = setsockopt(sock->sock, SOL_SOCKET, SO_BROADCAST, 1104 err = setsockopt(sock->sock, SOL_SOCKET, SO_BROADCAST,
1102 (char *) &bool, sizeof(bool)); 1105 (char *) &bool, sizeof(bool));
@@ -1104,15 +1107,18 @@ static int set_option(lua_State *L, p_sock sock)
1104 } 1107 }
1105 case 3: { 1108 case 3: {
1106 struct linger linger; 1109 struct linger linger;
1107 if (!lua_istable(L, -1)) return 0; 1110 if (!lua_istable(L, -1))
1111 lua_error(L, "invalid SO_LINGER value");
1108 lua_pushstring(L, "l_onoff"); 1112 lua_pushstring(L, "l_onoff");
1109 lua_gettable(L, -2); 1113 lua_gettable(L, -2);
1110 if (!lua_isnumber(L, -1)) return 0; 1114 if (!lua_isnumber(L, -1))
1115 lua_error(L, "invalid SO_LINGER (l_onoff) value");
1111 linger.l_onoff = lua_tonumber(L, -1); 1116 linger.l_onoff = lua_tonumber(L, -1);
1112 lua_pop(L, 1); 1117 lua_pop(L, 1);
1113 lua_pushstring(L, "l_linger"); 1118 lua_pushstring(L, "l_linger");
1114 lua_gettable(L, -2); 1119 lua_gettable(L, -2);
1115 if (!lua_isnumber(L, -1)) return 0; 1120 if (!lua_isnumber(L, -1))
1121 lua_error(L, "invalid SO_LINGER (l_linger) value");
1116 linger.l_linger = lua_tonumber(L, -1); 1122 linger.l_linger = lua_tonumber(L, -1);
1117 lua_pop(L, 1); 1123 lua_pop(L, 1);
1118 err = setsockopt(sock->sock, SOL_SOCKET, SO_LINGER, 1124 err = setsockopt(sock->sock, SOL_SOCKET, SO_LINGER,