Created
May 29, 2015 07:47
-
-
Save developerworks/a91e3a5e4b89f8e7b904 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
def init(args) do | |
Logger.debug "Starting multicast client with args: #{inspect args}" | |
case :gen_udp.open(@dvb_client_port, @client_socket_opts) do | |
{:ok, client_socket} -> | |
state = %{ | |
client_socket: client_socket, | |
packets: 0, | |
last_received_time: nil | |
} | |
{:ok, state, 1000} | |
{:error, reason} -> | |
Logger.error "Can not create socket, reason: #{inspect reason}" | |
{:stop, reason} | |
_ -> | |
Logger.error "Unkown return message" | |
{:stop, :unkown_return_message} | |
end | |
end | |
def handle_info(:timeout, %{client_socket: client_socket} = state) do | |
Logger.debug "Received message: #{inspect state}" | |
case :gen_udp.recv(client_socket, 0) do | |
{:ok, {address, port, packet}} -> | |
Logger.debug "Address: #{inspect address}, Port: #{inspect port}, Packet: #{inspect packet}" | |
{:error, reason} -> | |
Logger.debug "Error, reason: #{reason}" | |
end | |
{:noreply, state, @send_interval} | |
end | |
``` | |
Error message: | |
``` | |
15:43:31.573 [debug] Error, reason: einval | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment