static int luv_new_udp(lua_State* L) { uv_udp_t* handle = (uv_udp_t*)luv_newuserdata(L, sizeof(*handle)); int ret; if (lua_isnoneornil(L, 1)) { ret = uv_udp_init(luv_loop(L), handle); } else { ret = uv_udp_init_ex(luv_loop(L), handle, lua_tointeger(L, 1)); } if (ret < 0) { lua_pop(L, 1); return luv_error(L, ret); } handle->data = luv_setup_handle(L); return 1; }
int uv_udp_init(uv_loop_t* loop, uv_udp_t* handle) { return uv_udp_init_ex(loop, handle, AF_UNSPEC); }