luasocket and udp multicast

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

luasocket and udp multicast

Adrian Sietsma
This is primarily to Diego, but may be of interest to others.

Using luasocket to prototype some socket coding (which it is wonderful for),
I found one possible bug, and one feature I would like for completeness.

The code for setting multicast ttl (LuaSocket 2.02 and earlier) is :

int opt_ip_multicast_ttl(lua_State *L, p_socket ps)
{
     int val = (int) luaL_checknumber(L, 3);    /* obj, name, int */
     return opt_set(L, ps, SOL_SOCKET, SO_LINGER, (char *) &val, sizeof(val));
}

where I expected something like :

int opt_ip_multicast_ttl(lua_State *L, p_socket ps)
{
     int val = (int) luaL_checknumber(L, 3);    /* obj, name, int */
     return opt_set(L, ps, IPPROTO_IP, IP_MULTICAST_TTL, (char *) &val,
sizeof(val));
}


Also, can we have the option to set the outbound multicast interface ? The
call to be implemented is a wrapper for :

setsockopt(s, IPPROTO_IP, IP_MULTICAST_IF, &addr, sizeof(addr));


Adrian
Reply | Threaded
Open this post in threaded view
|

Re: luasocket and udp multicast

Diego Nehab-3
Hi Adrian,

> The code for setting multicast ttl (LuaSocket 2.02 and earlier) is :
>
> int opt_ip_multicast_ttl(lua_State *L, p_socket ps)
> {
>    int val = (int) luaL_checknumber(L, 3);    /* obj, name, int */
>    return opt_set(L, ps, SOL_SOCKET, SO_LINGER, (char *) &val, sizeof(val));
> }
>
> where I expected something like :
>
> int opt_ip_multicast_ttl(lua_State *L, p_socket ps)
> {
>    int val = (int) luaL_checknumber(L, 3);    /* obj, name, int */
>    return opt_set(L, ps, IPPROTO_IP, IP_MULTICAST_TTL, (char *) &val,
> sizeof(val));
> }
>
>
> Also, can we have the option to set the outbound multicast interface ? The
> call to be implemented is a wrapper for :
>
> setsockopt(s, IPPROTO_IP, IP_MULTICAST_IF, &addr, sizeof(addr));

Yes, let's work together on this. The multi-cast issue and a
bug on select are the only remaining problems before I
release LuaSocket 2.0.3.

Regards,
Diego