> On 8 Mar 2018, at 15:14, Tim Düsterhus <[email protected]> wrote: > > Hi > > Am 08.03.2018 um 15:10 schrieb Thierry Fournier: >> Ok, Lua expect the number of elements ins the stack. The right way for >> returning 1 is: >> >> lua_pushinteger(L, 1); >> return 1; >> > > Okay, then my patch probably worked, because of whatever value was left > on the stack. I learned something new here! > > Indeed the original socket class pushes `1` to the stack (but it uses > lua_pushnumber, instead of pushinteger). For the reference here's the > original line of code: > https://github.com/diegonehab/luasocket/blob/316a9455b9cb4637fe6e62b20fbe05f5141fec54/src/timeout.c#L172
Thanks for the search int the LuaSocket code. The doc doesn’t tell anything about the returned value. I think that the original patch worked because the top of the stack was the timeout value given as argument. Hey, the example of use of socket.http in attachment of your original commit is great ! 3 new patch in attachement to consider for the initial subject of this thread. BR, Thierry
0001-BUG-MINOR-lua-the-function-returns-anything.patch
Description: Binary data
0002-BUG-MINOR-lua-funtion-hlua_socket_settimeout-don-t-c.patch
Description: Binary data
0003-MINOR-lua-typo-fix.patch
Description: Binary data

