| Author |
Message |
|
| sam at inf.enst.fr |
Posted: Wed Dec 08, 1999 5:51 pm |
|
|
|
Guest
|
I decided to play with multicast sockets in Erlang, and discovered 3
problems with the following code:
-module (tm).
-export ([test/0]).
-include_lib ("kernel/src/inet_int.hrl").
-define (MULTIADDR, {224, 225, 224, 225}).
-define (MULTIPORT, 1501).
ip4_reverse ({A, B, C, D}) -> {D, C, B, A}.
test () ->
{ok, S} = inet_udp:open (?MULTIPORT, [{reuseadddr, 1},
{multicast_ttl, 16},
{multicast_loop, true},
{add_membership, {ip4_reverse (?MULTIADDR),
{0, 0, 0, 0}}}]),
inet_udp:send (S, ?MULTIADDR, ?MULTIPORT, "toto"),
receive
X ->
io:format ("~p~n", [X])
end,
inet_udp:close (S).
The three problems are:
(1) If an option is given an invalid name, or if it has a bad
argument, it is silently ignored. Try changing reuseaddr into
reuseaddddr, it should succeed. *WISHLIST*
(2) One needs to use {0, 0, 0, 0} to mean INADDR_ANY. Maybe ip_any/1
could be exported from inet.erl so that it can be used easily.
*WISHLIST*
(3) On my Intel Linux box, I need to reverse the multicast group
address given to setsockopt (..., ADD_MEMBERSHIP, ...). On my
Sparc box, I must NOT use this address reversing. There is some
suspicious code in inet_drv.c that may concern this:
L_set_mreq:
mreq_val.imr_multiaddr.s_addr = ival;
mreq_val.imr_interface.s_addr = get_int32(ptr);
I just wrote the following patch, but may not have the time to
have it tested tonight (I have no Erlang semi-compiled here). If
someone volunteers to test it, she will be welcome Otherwise,
I'll give the answer tomorrow.
--- erts/emulator/drivers/common/inet_drv.c.orig Wed Dec 8 18:46:00 1999
+++ erts/emulator/drivers/common/inet_drv.c Wed Dec 8 18:47:22 1999
_at__at_ -1514,8 +1514,8 _at__at_
type = IP_DROP_MEMBERSHIP;
DEBUGF(("Descriptor %d: [IPPROTO_IP] IP_DROP_MEMBERSHIP(%d)
",desc->s,ival));
L_set_mreq:
- mreq_val.imr_multiaddr.s_addr = ival;
- mreq_val.imr_interface.s_addr = get_int32(ptr);
+ mreq_val.imr_multiaddr.s_addr = sock_htonl (ival);
+ mreq_val.imr_interface.s_addr = sock_htonl (get_int32(ptr));
ptr += 4;
len -= 4;
arg_ptr = (char*)&mreq_val;
Sam
Post generated using Mail2Forum (http://m2f.sourceforge.net) |
|
|
| Back to top |
|
| sam at inf.enst.fr |
Posted: Thu Dec 09, 1999 11:40 am |
|
|
|
Guest
|
>>>>> "Sam" == Samuel Tardieu <sam_at_inf.enst.fr> writes:
Sam> I just wrote the following patch, but may not have the time
Sam> to have it tested tonight (I have no Erlang semi-compiled
Sam> here).
After applying and testing it, it looks like multicast now works
fine.e I repost the (tiny) patch for inclusion in Erlang.
Sam
--
Samuel Tardieu -- sam_at_inf.enst.fr
Post generated using Mail2Forum (http://m2f.sourceforge.net) |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
|