src/__unused/t_htp_srv.c
static int
lt_htp_srv_listen( lua_State *L )
{
	struct t_htp_srv        *s   = t_htp_srv_check_ud( L, 1, 1 );
	struct t_net_sck        *sc  = NULL;
	struct sockaddr_storage *ip  = NULL;
	int                      bl  = SOMAXCONN;

	// reuse socket:listen( )
	if (lua_isinteger( L, -1 ) && LUA_TSTRING != lua_type( L, -2 ))
	{
		bl = lua_tointeger( L, -1 );
		lua_pop( L, 1 );
	}
	p_net_sck_listen( L, sc, ip, bl );

	sc     = t_net_sck_check_ud( L, -2, 1 );
	ip     = t_net_adr_check_ud( L, -1, 1 );
	s->aR  = luaL_ref( L, LUA_REGISTRYINDEX );
	s->sck = sc;
	s->sR  = luaL_ref( L, LUA_REGISTRYINDEX );

	// TODO: cheaper to reimplement functionality -> less overhead?
	lua_pushcfunction( L, lt_ael_addhandle );   //S: srv addhandle
	lua_rawgeti( L, LUA_REGISTRYINDEX, s->lR );
	t_ael_check_ud( L, -1, 1 );
	lua_rawgeti( L, LUA_REGISTRYINDEX, s->sR );
	lua_pushstring( L, "read" );                //S: srv addhandle ael sck true
	lua_pushcfunction( L, lt_htp_srv_accept );  //S: srv addhandle ael sck true accept

	lua_pushvalue( L, 1 );                      //S: srv addhandle ael sck true accept srv

	//TODO: Check if that returns tru or false; if false resize loop
	lua_call( L, 5, 0 );
	lua_rawgeti( L, LUA_REGISTRYINDEX, s->sR );
	lua_rawgeti( L, LUA_REGISTRYINDEX, s->aR );
	//t_stackDump( L );
	return  2;
}
/**--------------------------------------------------------------------------
 * Puts the http server on a T.Loop to listen to incoming requests.
 * \param   L     Lua state.
 * \lparam  ud    T.Http.Server userdata instance.
 * \lreturn mult  from the buffer a packers position according to packer format.
 * \return  int    # of values pushed onto the stack.
 *  -------------------------------------------------------------------------*/
Puts the http server on a T.Loop to listen to incoming requests.
\param   L     Lua state.
\lparam  ud    T.Http.Server userdata instance.
\lreturn mult  from the buffer a packers position according to packer format.
\return  int    # of values pushed onto the stack.
Puts the http server on a T . Loop to listen to incoming requests . \ param L Lua state . \ lparam ud T . Http . Server userdata instance . \ lreturn mult from the buffer a packers position according to packer format . \ return int # of values pushed onto the stack .
static int
lt_htp_srv_listen( lua_State *L )
{
	struct t_htp_srv        *s   = t_htp_srv_check_ud( L, 1, 1 );
	struct t_net_sck        *sc  = NULL;
	struct sockaddr_storage *ip  = NULL;
	int                      bl  = SOMAXCONN;
	if (lua_isinteger( L, -1 ) && LUA_TSTRING != lua_type( L, -2 ))
	{
		bl = lua_tointeger( L, -1 );
		lua_pop( L, 1 );
	}
	p_net_sck_listen( L, sc, ip, bl );
	sc     = t_net_sck_check_ud( L, -2, 1 );
	ip     = t_net_adr_check_ud( L, -1, 1 );
	s->aR  = luaL_ref( L, LUA_REGISTRYINDEX );
	s->sck = sc;
	s->sR  = luaL_ref( L, LUA_REGISTRYINDEX );
	lua_pushcfunction( L, lt_ael_addhandle );   
	lua_rawgeti( L, LUA_REGISTRYINDEX, s->lR );
	t_ael_check_ud( L, -1, 1 );
	lua_rawgeti( L, LUA_REGISTRYINDEX, s->sR );
	lua_pushstring( L, "read" );                 ael sck true
	lua_pushcfunction( L, lt_htp_srv_accept );   ael sck true accept
	lua_pushvalue( L, 1 );                       ael sck true accept srv
	lua_call( L, 5, 0 );
	lua_rawgeti( L, LUA_REGISTRYINDEX, s->sR );
	lua_rawgeti( L, LUA_REGISTRYINDEX, s->aR );
	return  2;
}
static int lt_htp_srv_listen ( lua_State * L ) { struct t_htp_srv * s = t_htp_srv_check_ud ( L , 1 , 1 ) ; struct t_net_sck * sc = NULL ; struct sockaddr_storage * ip = NULL ; int bl = SOMAXCONN ; if ( lua_isinteger ( L , -1 ) && LUA_TSTRING != lua_type ( L , -2 ) ) { bl = lua_tointeger ( L , -1 ) ; lua_pop ( L , 1 ) ; } p_net_sck_listen ( L , sc , ip , bl ) ; sc = t_net_sck_check_ud ( L , -2 , 1 ) ; ip = t_net_adr_check_ud ( L , -1 , 1 ) ; s -> aR = luaL_ref ( L , LUA_REGISTRYINDEX ) ; s -> sck = sc ; s -> sR = luaL_ref ( L , LUA_REGISTRYINDEX ) ; lua_pushcfunction ( L , lt_ael_addhandle ) ; lua_rawgeti ( L , LUA_REGISTRYINDEX , s -> lR ) ; t_ael_check_ud ( L , -1 , 1 ) ; lua_rawgeti ( L , LUA_REGISTRYINDEX , s -> sR ) ; lua_pushstring ( L , " " ) ; lua_pushcfunction ( L , lt_htp_srv_accept ) ; lua_pushvalue ( L , 1 ) ; lua_call ( L , 5 , 0 ) ; lua_rawgeti ( L , LUA_REGISTRYINDEX , s -> sR ) ; lua_rawgeti ( L , LUA_REGISTRYINDEX , s -> aR ) ; return 2 ; }
Puts the http server on a T.Loop to listen to incoming requests.
Puts the http server on a T . Loop to listen to incoming requests .
// reuse socket:listen( ) // TODO: cheaper to reimplement functionality -> less overhead? //S: srv addhandle //S: srv addhandle ael sck true //S: srv addhandle ael sck true accept //S: srv addhandle ael sck true accept srv //TODO: Check if that returns tru or false; if false resize loop //t_stackDump( L );