Permalink
Browse files

net: fix multicast on sunos

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...
1 parent accc34c commit 8f245486aa86391a71786b541d47d4c950aef9bd @bnoordhuis bnoordhuis committed Aug 24, 2011
Showing with 14 additions and 3 deletions.
  1. +14 −3 src/node_net.cc
View
@@ -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));
@@ -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])

0 comments on commit 8f24548

Please sign in to comment.