Skip to content

Commit

Permalink
Also allow passing flags in new_udp
Browse files Browse the repository at this point in the history
  • Loading branch information
creationix committed Apr 7, 2016
1 parent 8b6acd1 commit ff03f54
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ static uv_udp_t* luv_check_udp(lua_State* L, int index) {

static int luv_new_udp(lua_State* L) {
uv_udp_t* handle = luv_newuserdata(L, sizeof(*handle));
int ret = uv_udp_init(luv_loop(L), 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);
Expand Down

0 comments on commit ff03f54

Please sign in to comment.