Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
net: fix multicast on sunos
Browse files Browse the repository at this point in the history
setsockopt(IP_MULTICAST_TTL|IP_MULTICAST_LOOP) takes an unsigned char as
its argument on sunos.

Partially fixes simple/test-dgram-multicast: test hangs after socket
close but it no longer throws EINVAL exceptions.
  • Loading branch information
bnoordhuis committed Aug 24, 2011
1 parent accc34c commit 8f24548
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/node_net.cc
Expand Up @@ -1431,12 +1431,18 @@ static Handle<Value> SetMulticastTTL(const Arguments& args) {
String::New("Argument must be a number")));
}

int newttl = args[1]->Int32Value();
if (newttl < 0 || newttl > 255) {
int value = args[1]->Int32Value();
if (value < 0 || value > 255) {
return ThrowException(Exception::TypeError(
String::New("new MulticastTTL must be between 0 and 255")));
}

#ifdef __sun
unsigned char newttl = (unsigned char) value;
#else
int newttl = value;
#endif

int r = setsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL,
reinterpret_cast<void*>(&newttl), sizeof(newttl));

Expand All @@ -1448,7 +1454,12 @@ static Handle<Value> SetMulticastTTL(const Arguments& args) {
}

static Handle<Value> SetMulticastLoopback(const Arguments& args) {
int flags, r;
#ifdef __sun
unsigned char flags;
#else
int flags;
#endif
int r;
HandleScope scope;

FD_ARG(args[0])
Expand Down

0 comments on commit 8f24548

Please sign in to comment.