Last active
May 9, 2016 18:38
-
-
Save alexnsolo/212cfd60ea467a68732f8af528102320 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
defmodule AcmeUdpLogger.MessageReceiver do | |
use GenServer | |
def start_link(opts \\ []) do | |
GenServer.start_link(__MODULE__, :ok, opts) | |
end | |
def init (:ok) do | |
{:ok, _socket} = :gen_udp.open(21337) | |
end | |
# Handle UDP data | |
def handle_info({:udp, _socket, _ip, _port, data}, state) do | |
{:noreply, state} | |
end | |
# Ignore everything else | |
def handle_info({_, _socket}, state) do | |
{:noreply, state} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment