资源简介
skynet实现的斗地主服务端源码,斗地主规则有改动,逻辑用lua实现
代码片段和文件信息
/* ares_aresolve.c
*
* provide asynchronous dns lookup support. This is a companion lib to
* lsocket but can also be used without it.
*
* Gunnar Zötl 2013
* Released under MIT/X11 license. See file LICENSE for details.
*/
#include
#include
#include
#include “gai_async.h“
#include
#include
#include
#include
#include
#include “lua.h“
#include “lauxlib.h“
#if LUA_VERSION_NUM == 501
#define luaL_newlib(Lfuncs) lua_newtable(L); luaL_register(L NULL funcs)
#define luaL_setfuncs(Lfuncsx) luaL_register(L NULL funcs)
#endif
#define ARESOLVER “socket_aresolver“
#define TOSTRING_BUFSIZ 64
#define LSOCKET_INET “inet“
#define LSOCKET_INET6 “inet6“
/* structure for asynch resolver userdata */
typedef struct _aresolver {
struct gai_request *rq;
} aResolver;
/* ares_checkaResolver
*
* Checks whether the item at the index on the lua stack is a userdata of
* the type ARESOLVER. If so returns its block address else
* throw an error.
*
* Arguments:
* L Lua State
* index stack index where the userdata is expected
*/
static aResolver* ares_checkaResolver(lua_State *L int index)
{
aResolver *ares = (aResolver*) luaL_checkudata(L index ARESOLVER);
return ares;
}
/* ares_pushaResolver
*
* create a new empty aResolver userdata attach its metatable
* and push it to the stack.
*
* Arguments:
* L Lua state
*
* Lua Returns:
* +1 aResolver userdata
*/
static aResolver* ares_pushaResolver(lua_State *L)
{
aResolver *ares = (aResolver*) lua_newuserdata(L sizeof(aResolver));
luaL_getmetatable(L ARESOLVER);
lua_setmetatable(L -2);
return ares;
}
/*** Housekeeping metamethods ***/
/* ares__gc
*
* __gc metamethod for the ares userdata.
* cancels request if
*
* Arguments:
* L Lua State
*
* Lua Stack:
* 1 aResolver userdata
*/
static int ares__gc(lua_State *L)
{
aResolver *ares = (aResolver*) lua_touserdata(L 1);
void *dummy;
gai_cancel(ares->rq);
gai_finalize(ares->rq (struct addrinfo **) &dummy);
ares->rq = NULL;
return 0;
}
/* ares__toString
*
* __tostring metamethod for the lsock userdata.
* Returns a string representation of the aResolver
*
* Arguments:
* L Lua State
*
* Lua Stack:
* 1 aResolver userdata
*
* Lua Returns:
* +1 string representation of aResolver userdata
*/
static int ares__toString(lua_State *L)
{
aResolver *ares = ares_checkaResolver(L 1);
char buf[TOSTRING_BUFSIZ];
if (snprintf(buf TOSTRING_BUFSIZ “%s: %p“ ARESOLVER ares) >= TOSTRING_BUFSIZ)
return luaL_error(L “Whoopsie... the string representation seems to be too long.“);
/* this should not happen just to be sure! */
lua_pushstring(L buf);
return 1;
}
/* metamethods for the ares userdata
*/
static const luaL_Reg ares_meta[] = {
{“__gc“ ares__gc}
{“__tostring“ ares__toString}
{0 0}
};
/*** global helper functions ***/
/* ares_error
*
* pushes nil and an error message onto the
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
I.A.... 259 2018-10-19 09:31 sample_lua.config
I.A.... 12976 2018-10-19 09:32 sample_lua.luaproj
I.A.... 94 2018-10-19 09:32 pk_landlord\.gitignore
I.A.... 96 2018-10-19 09:32 pk_landlord\.gitmodules
I.A.... 424 2018-10-19 09:32 pk_landlord\cfg_friend\ConfigGame.lua
I.A.... 410 2018-10-19 09:32 pk_landlord\cfg_guide\ConfigGame.lua
I.A.... 412 2018-10-19 09:32 pk_landlord\cfg_ranking\ConfigGame.lua
I.A.... 416 2018-10-19 09:32 pk_landlord\cfg_ren_android\ConfigGame.lua
I.A.... 424 2018-10-19 09:32 pk_landlord\cfg_ren_ren\ConfigGame.lua
I.A.... 1275 2018-10-19 09:32 pk_landlord\client\simpleclient.lua
I.A.... 2157 2018-10-19 09:32 pk_landlord\client\simplemessage.lua
I.A.... 1221 2018-10-19 09:32 pk_landlord\client\simplesocket.lua
I.A.... 112 2018-10-19 09:32 pk_landlord\client.sh
I.A.... 1275 2018-10-19 09:32 pk_landlord\client_dir\simpleclient.lua
I.A.... 2157 2018-10-19 09:32 pk_landlord\client_dir\simplemessage.lua
I.A.... 1221 2018-10-19 09:32 pk_landlord\client_dir\simplesocket.lua
I.A.... 515 2018-10-19 09:32 pk_landlord\config
I.A.... 736 2018-10-19 09:32 pk_landlord\config_dir
I.A.... 856 2018-10-19 09:32 pk_landlord\config_game
I.A.... 810 2018-10-19 09:32 pk_landlord\config_game_2
I.A.... 876 2018-10-19 09:32 pk_landlord\config_game_friend
I.A.... 860 2018-10-19 09:32 pk_landlord\config_game_guide
I.A.... 864 2018-10-19 09:32 pk_landlord\config_game_ranking
I.A.... 873 2018-10-19 09:32 pk_landlord\config_game_ren_android
I.A.... 877 2018-10-19 09:32 pk_landlord\config_lobby
I.A.... 833 2018-10-19 09:32 pk_landlord\config_login
I.A.... 834 2018-10-19 09:32 pk_landlord\config_manage
I.A.... 869 2018-10-19 09:32 pk_landlord\config_routinue
I.A.... 887 2018-10-19 09:32 pk_landlord\config_stress_test
I.A.... 515 2018-10-19 09:32 pk_landlord\config_test
............此处省略1674个文件信息
评论
共有 条评论