Skip to content

Commit

Permalink
replace setopt/3 with setopt/4
Browse files Browse the repository at this point in the history
  • Loading branch information
petermm authored and fhunleth committed Sep 23, 2021
1 parent 0ac9139 commit 3c9b018
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions lib/mdns_lite/responder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,15 @@ defmodule MdnsLite.Responder do
{:ok, udp} = :socket.open(:inet, :dgram, :udp)

:ok = bindtodevice(udp, state.ifname)
:ok = :socket.setopt(udp, {:socket, :reuseport}, true)
:ok = :socket.setopt(udp, {:socket, :reuseaddr}, true)
:ok = :socket.setopt(udp, {:ip, :multicast_loop}, false)
:ok = :socket.setopt(udp, :socket, :reuseport, true)
:ok = :socket.setopt(udp, :socket, :reuseaddr, true)
:ok = :socket.setopt(udp, :ip, :multicast_loop, false)
# IP TTL should be 255. See https://tools.ietf.org/html/rfc6762#section-11
:ok = :socket.setopt(udp, {:ip, :multicast_ttl}, 255)
:ok = :socket.setopt(udp, {:ip, :multicast_if}, state.ip)
:ok = :socket.setopt(udp, :ip, :multicast_ttl, 255)
:ok = :socket.setopt(udp, :ip, :multicast_if, state.ip)
:ok = :socket.bind(udp, %{family: :inet, port: @mdns_port})

:ok =
:socket.setopt(udp, {:ip, :add_membership}, %{multiaddr: @mdns_ipv4, interface: state.ip})
:ok = :socket.setopt(udp, :ip, :add_membership, %{multiaddr: @mdns_ipv4, interface: state.ip})

new_state = %{state | udp: udp} |> process_receives()
{:noreply, new_state}
Expand Down Expand Up @@ -283,7 +282,7 @@ defmodule MdnsLite.Responder do
defp bindtodevice(socket, ifname) do
case :os.type() do
{:unix, :linux} ->
:socket.setopt(socket, {:socket, :bindtodevice}, String.to_charlist(ifname))
:socket.setopt(socket, :socket, :bindtodevice, String.to_charlist(ifname))

{:unix, :darwin} ->
# TODO!
Expand Down

0 comments on commit 3c9b018

Please sign in to comment.