src/__unused/t_htp_srv.c
static int
lt_htp_srv_accept( lua_State *L )
{
	struct t_htp_srv        *s      = (struct t_htp_srv *) lua_touserdata( L, 1 );
	struct sockaddr_storage *si_cli = NULL;
	struct t_net_sck        *c_sck  = NULL;
	struct t_net_sck        *s_sck  = NULL;
	struct t_ael            *ael;    // AELoop
	struct t_htp_con        *c;      // new message userdata

	lua_rawgeti( L, LUA_REGISTRYINDEX, s->sR );
	s_sck = t_net_sck_check_ud( L, -1, 1 );

	p_net_sck_accept( L, s_sck, c_sck, si_cli );   //S: srv,ssck,csck,cip
	//t_net_reuseaddr( L, c_sck );

	// prepare the ael_fd->wR table on stack
	lua_newtable( L );
	lua_pushcfunction( L, t_htp_con_rsp ); //S: s,ss,cs,ip,rt,rsp
	lua_rawseti( L, -2, 1 );

	lua_pushcfunction( L, lt_ael_addhandle );
	lua_rawgeti( L, LUA_REGISTRYINDEX, s->lR );
	ael = t_ael_check_ud( L, -1, 1 );      //S: s,ss,cs,ip,rt,add(),ael
	lua_pushvalue( L, -5 );                // push client socket
	lua_pushboolean( L, 1 );               // yepp, that's for reading
	lua_pushcfunction( L, t_htp_con_rcv ); //S: s,ss,cs,ip,rt,add(),ael,cs,true,rcv
	c = t_htp_con_create_ud( L, s );
	lua_pushvalue( L, -1 );                // preserve to put onto rsp function
	lua_rawseti( L, -8, 2 );
	lua_newtable( L );                     // create connection proxy table
	lua_pushstring( L, "socket" );
	lua_pushvalue( L, -11 );  //S: s,ss,cs,ip,rt,add(),ael,cs,true,rcv,msg,proxy,"socket",cs
	lua_rawset( L, -3 );
	lua_pushstring( L, "ip" );
	lua_pushvalue( L, -10 );  //S: s,ss,cs,ip,rt,add(),ael,cs,true,rcv,msg,proxy,"ip",ip
	lua_rawset( L, -3 );
	c->pR  = luaL_ref( L, LUA_REGISTRYINDEX );
	c->sck = c_sck;

	// actually put it onto the loop  //S: s,ss,cs,ip,rt,add(),ael,cs,true,rcv,msg
	lua_call( L, 5, 0 );          // execute ael:addhandle(cli,tread,rcv,msg)
	// Here the t_ael_fd is all allocated and set up for reading.  This will put
	// the response writer method on the ->wR reference for faster processing
	// since an HTTP msg will bounce back and forth between reading and writing.
	//S: s,ss,cs,ip,rt,(true/false)
	//lua_pop( L, 1 );                           // TODO: pop true or false
	ael->fdSet[ c->sck->fd ]->wR = luaL_ref( L, LUA_REGISTRYINDEX );
	return 0;
}
/**--------------------------------------------------------------------------
 * Accept a connection from a Http.Server listener.
 * Called anytime a new connection gets established.
 * \param   L     lua Virtual Machine.
 * \lparam  userdata  struct t_htp_srv.
 * \param   pointer to the buffer to read from(already positioned).
 * \lreturn value from the buffer a packers position according to packer format.
 * \return  int    # of values pushed onto the stack.
 *  -------------------------------------------------------------------------*/
Accept a connection from a Http.Server listener.
Called anytime a new connection gets established.
\param   L     lua Virtual Machine.
\lparam  userdata  struct t_htp_srv.
\param   pointer to the buffer to read from(already positioned).
\lreturn value from the buffer a packers position according to packer format.
\return  int    # of values pushed onto the stack.
Accept a connection from a Http . Server listener . Called anytime a new connection gets established . \ param L lua Virtual Machine . \ lparam userdata struct t_htp_srv . \ param pointer to the buffer to read from ( already positioned ) . \ lreturn value from the buffer a packers position according to packer format . \ return int # of values pushed onto the stack .
static int
lt_htp_srv_accept( lua_State *L )
{
	struct t_htp_srv        *s      = (struct t_htp_srv *) lua_touserdata( L, 1 );
	struct sockaddr_storage *si_cli = NULL;
	struct t_net_sck        *c_sck  = NULL;
	struct t_net_sck        *s_sck  = NULL;
	struct t_ael            *ael;    
	struct t_htp_con        *c;      
	lua_rawgeti( L, LUA_REGISTRYINDEX, s->sR );
	s_sck = t_net_sck_check_ud( L, -1, 1 );
	p_net_sck_accept( L, s_sck, c_sck, si_cli );   
	lua_newtable( L );
	lua_pushcfunction( L, t_htp_con_rsp ); 
	lua_rawseti( L, -2, 1 );
	lua_pushcfunction( L, lt_ael_addhandle );
	lua_rawgeti( L, LUA_REGISTRYINDEX, s->lR );
	ael = t_ael_check_ud( L, -1, 1 );      
	lua_pushvalue( L, -5 );                
	lua_pushboolean( L, 1 );               
	lua_pushcfunction( L, t_htp_con_rcv ); ,cs,true,rcv
	c = t_htp_con_create_ud( L, s );
	lua_pushvalue( L, -1 );                
	lua_rawseti( L, -8, 2 );
	lua_newtable( L );                     
	lua_pushstring( L, "socket" );
	lua_pushvalue( L, -11 );  ,cs,true,rcv,msg,proxy,"socket",cs
	lua_rawset( L, -3 );
	lua_pushstring( L, "ip" );
	lua_pushvalue( L, -10 );  ,cs,true,rcv,msg,proxy,"ip",ip
	lua_rawset( L, -3 );
	c->pR  = luaL_ref( L, LUA_REGISTRYINDEX );
	c->sck = c_sck;
	// actually put it onto the loop  ,cs,true,rcv,msg
	lua_call( L, 5, 0 );          
	ael->fdSet[ c->sck->fd ]->wR = luaL_ref( L, LUA_REGISTRYINDEX );
	return 0;
}
static int lt_htp_srv_accept ( lua_State * L ) { struct t_htp_srv * s = ( struct t_htp_srv * ) lua_touserdata ( L , 1 ) ; struct sockaddr_storage * si_cli = NULL ; struct t_net_sck * c_sck = NULL ; struct t_net_sck * s_sck = NULL ; struct t_ael * ael ; struct t_htp_con * c ; lua_rawgeti ( L , LUA_REGISTRYINDEX , s -> sR ) ; s_sck = t_net_sck_check_ud ( L , -1 , 1 ) ; p_net_sck_accept ( L , s_sck , c_sck , si_cli ) ; lua_newtable ( L ) ; lua_pushcfunction ( L , t_htp_con_rsp ) ; lua_rawseti ( L , -2 , 1 ) ; lua_pushcfunction ( L , lt_ael_addhandle ) ; lua_rawgeti ( L , LUA_REGISTRYINDEX , s -> lR ) ; ael = t_ael_check_ud ( L , -1 , 1 ) ; lua_pushvalue ( L , -5 ) ; lua_pushboolean ( L , 1 ) ; lua_pushcfunction ( L , t_htp_con_rcv ) ; c = t_htp_con_create_ud ( L , s ) ; lua_pushvalue ( L , -1 ) ; lua_rawseti ( L , -8 , 2 ) ; lua_newtable ( L ) ; lua_pushstring ( L , " " ) ; lua_pushvalue ( L , -11 ) ; lua_rawset ( L , -3 ) ; lua_pushstring ( L , " " ) ; lua_pushvalue ( L , -10 ) ; lua_rawset ( L , -3 ) ; c -> pR = luaL_ref ( L , LUA_REGISTRYINDEX ) ; c -> sck = c_sck ; lua_call ( L , 5 , 0 ) ; ael -> fdSet [ c -> sck -> fd ] -> wR = luaL_ref ( L , LUA_REGISTRYINDEX ) ; return 0 ; }
Accept a connection from a Http.Server listener.
Accept a connection from a Http . Server listener .
// AELoop // new message userdata //S: srv,ssck,csck,cip //t_net_reuseaddr( L, c_sck ); // prepare the ael_fd->wR table on stack //S: s,ss,cs,ip,rt,rsp //S: s,ss,cs,ip,rt,add(),ael // push client socket // yepp, that's for reading //S: s,ss,cs,ip,rt,add(),ael,cs,true,rcv // preserve to put onto rsp function // create connection proxy table //S: s,ss,cs,ip,rt,add(),ael,cs,true,rcv,msg,proxy,"socket",cs //S: s,ss,cs,ip,rt,add(),ael,cs,true,rcv,msg,proxy,"ip",ip // actually put it onto the loop  //S: s,ss,cs,ip,rt,add(),ael,cs,true,rcv,msg // execute ael:addhandle(cli,tread,rcv,msg) // Here the t_ael_fd is all allocated and set up for reading.  This will put // the response writer method on the ->wR reference for faster processing // since an HTTP msg will bounce back and forth between reading and writing. //S: s,ss,cs,ip,rt,(true/false) //lua_pop( L, 1 );                           // TODO: pop true or false