summaryrefslogtreecommitdiff
path: root/src/ivysocket.c
diff options
context:
space:
mode:
authorfcolin2000-12-20 16:47:19 +0000
committerfcolin2000-12-20 16:47:19 +0000
commitd47112e5481abb3004811cd0ae6d270c24461d9c (patch)
tree6d7eca5fbd53af0b1614fc9f4045be89db59af59 /src/ivysocket.c
parent2a5b456e050011846b366062403ae3f9ec45fedb (diff)
downloadivy-c-d47112e5481abb3004811cd0ae6d270c24461d9c.zip
ivy-c-d47112e5481abb3004811cd0ae6d270c24461d9c.tar.gz
ivy-c-d47112e5481abb3004811cd0ae6d270c24461d9c.tar.bz2
ivy-c-d47112e5481abb3004811cd0ae6d270c24461d9c.tar.xz
multicast and glut eventloop support
Diffstat (limited to 'src/ivysocket.c')
-rw-r--r--src/ivysocket.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/ivysocket.c b/src/ivysocket.c
index 9d40f3d..582d227 100644
--- a/src/ivysocket.c
+++ b/src/ivysocket.c
@@ -579,3 +579,39 @@ void SocketSendBroadcast (Client client, unsigned long host, unsigned short port
perror ("*** send ***");
} va_end (ap );
}
+
+/* Socket Multicast */
+
+int SocketAddMember(Client client, unsigned long host )
+{
+ struct ip_mreq imr;
+/*
+Multicast datagrams with initial TTL 0 are restricted to the same host.
+Multicast datagrams with initial TTL 1 are restricted to the same subnet.
+Multicast datagrams with initial TTL 32 are restricted to the same site.
+Multicast datagrams with initial TTL 64 are restricted to the same region.
+Multicast datagrams with initial TTL 128 are restricted to the same continent.
+Multicast datagrams with initial TTL 255 are unrestricted in scope.
+*/
+ unsigned char ttl = 64 ; // Arbitrary TTL value.
+ /* wee need to broadcast */
+
+ imr.imr_multiaddr.s_addr = htonl( host );
+ imr.imr_interface.s_addr = INADDR_ANY;
+ if(setsockopt(client->fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *)&imr,sizeof(struct ip_mreq)) == -1 )
+ {
+ perror("setsockopt() Cannot join group");
+ fprintf(stderr, "Does your kernel support IP multicast extensions ?\n");
+ return 0;
+ }
+
+ if(setsockopt(client->fd, IPPROTO_IP, IP_MULTICAST_TTL, (char *)&ttl, sizeof(ttl)) < 0 )
+ {
+ perror("setsockopt() Cannot set TTL");
+ fprintf(stderr, "Does your kernel support IP multicast extensions ?\n");
+ return 0;
+ }
+
+ return 1;
+}
+