1. EuNET Multicast parameter

This is the syntax for a C IP_ADD_MEMBERSHIP

imreq.imr_multiaddr.s_addr = inet_addr("224.0.0.1"); imreq.imr_interface.s_addr = INADDR_ANY; use DEFAULT interface

JOIN multicast group on default interface status = setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const void *)&imreq, sizeof(struct ip_mreq));

What is the syntax for the EuNet IP_ADD_MEMBERSHIP

eunet_set_socket_options(atom socket, integer level, integer optname, object val)

eunet_set_socket_options(socket, IPROTO_IP, IP_ADD_MEMBERSHIP, object val)

What are the perameters for <object val> ??? Thanks,

Elias

new topic     » topic index » view message » categorize

2. Re: EuNET Multicast parameter

IP_ADD_MEMBERSHIP takes a pointer to a 32-byte structure as its value.

This hasn't been tested, but the general idea is this:

  addr = {244,0,0,1,0} -- Multicast address & port 
  sockaddr = allocate(32) 
  poke(sockaddr,{AF_INET,0}) 
  poke(sockaddr+2,floor(addr[5]/256)) -- port hi 
  poke(sockaddr+3,remainder(addr[5],256)) -- port low 
  poke(sockaddr+4,addr[1..4]) 
  poke(sockaddr+8,{0,0,0,0,0,0,0,0}) 
 
  addr_i = {192,168,0,1,0}  -- Interface address & port 
  poke(sockaddr+16,{AF_INET,0}) 
  poke(sockaddr+18,floor(addr_i[5]/256)) -- port hi 
  poke(sockaddr+19,remainder(addr_i[5],256)) -- port low 
  poke(sockaddr+20,addr_i[1..4]) 
  poke(sockaddr+24,{0,0,0,0,0,0,0,0}) 
 
  success = eunet_set_socket_options(socket,IP_PROTO,IP_ADD_MEMBERSHIP,sockaddr) 

Hope this helps.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu