diff options
Diffstat (limited to 'src/udp.c')
-rw-r--r-- | src/udp.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -335,12 +335,14 @@ static int meth_settimeout(lua_State *L) | |||
335 | static int meth_setpeername(lua_State *L) | 335 | static int meth_setpeername(lua_State *L) |
336 | { | 336 | { |
337 | p_udp udp = (p_udp) aux_checkclass(L, "udp{unconnected}", 1); | 337 | p_udp udp = (p_udp) aux_checkclass(L, "udp{unconnected}", 1); |
338 | p_tm tm = &udp->tm; | ||
338 | const char *address = luaL_checkstring(L, 2); | 339 | const char *address = luaL_checkstring(L, 2); |
339 | int connecting = strcmp(address, "*"); | 340 | int connecting = strcmp(address, "*"); |
340 | unsigned short port = connecting ? | 341 | unsigned short port = connecting ? |
341 | (unsigned short) luaL_checknumber(L, 3) : | 342 | (unsigned short) luaL_checknumber(L, 3) : |
342 | (unsigned short) luaL_optnumber(L, 3, 0); | 343 | (unsigned short) luaL_optnumber(L, 3, 0); |
343 | const char *err = inet_tryconnect(&udp->sock, address, port); | 344 | const char *err; |
345 | err = inet_tryconnect(&udp->sock, address, port, tm_getfailure(tm)); | ||
344 | if (err) { | 346 | if (err) { |
345 | lua_pushnil(L); | 347 | lua_pushnil(L); |
346 | lua_pushstring(L, err); | 348 | lua_pushstring(L, err); |