diff options
author | Dan VerWeire <dverweire@gmail.com> | 2011-10-27 18:48:38 +0400 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2012-01-21 06:26:04 +0400 |
commit | f749338e1eee390fc654f129f4419895db4f8e50 (patch) | |
tree | 390d7abef2e2a033ef83bc19b0e741b0586299ae /src | |
parent | a38fd6056c2c6d4e2266a65fdefdbdc8dcbe4dee (diff) |
dgram: reintroduce setBroadcast()
Removed during the early stages of node 0.5 refactoring to libuv.
Diffstat (limited to 'src')
-rw-r--r-- | src/udp_wrap.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc index 5b2fb52923c..e73f634cde6 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -93,6 +93,7 @@ public: static Handle<Value> GetSockName(const Arguments& args); static Handle<Value> AddMembership(const Arguments& args); static Handle<Value> DropMembership(const Arguments& args); + static Handle<Value> SetBroadcast(const Arguments& args); private: static inline char* NewSlab(v8::Handle<v8::Object> global, v8::Handle<v8::Object> wrap_obj); @@ -153,6 +154,7 @@ void UDPWrap::Initialize(Handle<Object> target) { NODE_SET_PROTOTYPE_METHOD(t, "getsockname", GetSockName); NODE_SET_PROTOTYPE_METHOD(t, "addMembership", AddMembership); NODE_SET_PROTOTYPE_METHOD(t, "dropMembership", DropMembership); + NODE_SET_PROTOTYPE_METHOD(t, "setBroadcast", SetBroadcast); target->Set(String::NewSymbol("UDP"), Persistent<FunctionTemplate>::New(t)->GetFunction()); @@ -209,6 +211,20 @@ Handle<Value> UDPWrap::Bind6(const Arguments& args) { return DoBind(args, AF_INET6); } +Handle<Value> UDPWrap::SetBroadcast(const Arguments& args) { + HandleScope scope; + UNWRAP + + assert(args.Length() == 1); + + int on = args[0]->Uint32Value(); + int r = uv_udp_set_broadcast(&wrap->handle_, on); + + if (r) + SetErrno(uv_last_error(uv_default_loop())); + + return scope.Close(Integer::New(r)); +} Handle<Value> UDPWrap::SetMembership(const Arguments& args, uv_membership membership) { |