Added proxy support to http.lua

Changed callback.lua module, but need more work.
Added local connect support.
This commit is contained in:
Diego Nehab 2004-01-19 00:24:41 +00:00
parent 3ea9271126
commit 6ac82d50ee
4 changed files with 125 additions and 67 deletions

View file

@ -230,15 +230,15 @@ static int meth_bind(lua_State *L)
p_tcp tcp = (p_tcp) aux_checkclass(L, "tcp{master}", 1);
const char *address = luaL_checkstring(L, 2);
unsigned short port = (unsigned short) luaL_checknumber(L, 3);
int backlog = (int) luaL_optnumber(L, 4, 0);
int backlog = (int) luaL_optnumber(L, 4, 1);
const char *err = inet_trybind(&tcp->sock, address, port, backlog);
if (err) {
lua_pushnil(L);
lua_pushstring(L, err);
return 2;
}
/* turn master object into a server object */
aux_setclass(L, "tcp{server}", 1);
/* turn master object into a server object if there was a listen */
if (backlog > 0) aux_setclass(L, "tcp{server}", 1);
lua_pushnumber(L, 1);
return 1;
}