Permalink
Browse files

even more defensive with lan init

  • Loading branch information...
1 parent 2172da3 commit 3c2df6814f8c0b259564b9e0d93a08a6657479c0 @RJ committed Nov 26, 2009
Showing with 13 additions and 9 deletions.
  1. +13 −9 playdar_modules/lan/src/lan_resolver.erl
@@ -45,15 +45,19 @@ init([]) ->
{add_membership, {BC, LAddr}}]) of
{ok, Sock} ->
% Normal socket, which direct replies are sent to:
- {ok, SockP}= gen_udp:open(Port, [binary,
- {reuseaddr, true}, {ip, {0,0,0,0}}]),
- playdar_resolver:add_resolver(?MODULE, self()),
- {ok, #state{sock=Sock,
- sockp=SockP,
- seenqids=SQ,
- broadcast=BC,
- port=Port
- }};
+ case gen_udp:open(Port, [binary,
+ {reuseaddr, true}, {ip, {0,0,0,0}}]) of
+ {ok, SockP} ->
+ playdar_resolver:add_resolver(?MODULE, self()),
+ {ok, #state{sock=Sock,
+ sockp=SockP,
+ seenqids=SQ,
+ broadcast=BC,
+ port=Port
+ }};
+ Errr ->
+ ?LOG(error, "Failed to initialise LAN resolver. Couldn't listen on 0.0.0.0: ~p", [Errr])
+ end;
Err ->
?LOG(error, "Failed to initialise LAN resolver. Probably a network/multicast issue: ~p",[Err]),
ignore

0 comments on commit 3c2df68

Please sign in to comment.