Update the return values of socket.listen, also return the real port bind to zero (#1638)

This commit is contained in:
zaxbbun
2022-09-03 07:19:03 +08:00
committed by GitHub
parent 6bd6f53ab8
commit c1eeba215d
10 changed files with 30 additions and 18 deletions

View File

@@ -488,13 +488,14 @@ llisten(lua_State *L) {
int port = luaL_checkinteger(L,2);
int backlog = luaL_optinteger(L,3,BACKLOG);
struct skynet_context * ctx = lua_touserdata(L, lua_upvalueindex(1));
int id = skynet_socket_listen(ctx, host,port,backlog);
int id = skynet_socket_listen(ctx, host, &port, backlog);
if (id < 0) {
return luaL_error(L, "Listen error");
}
lua_pushinteger(L,id);
return 1;
lua_pushinteger(L,port);
return 2;
}
static size_t