Skip to content

Instantly share code, notes, and snippets.

@blt
Created April 3, 2015 20:48
Show Gist options
  • Save blt/1c8551fea9a37d5eb88d to your computer and use it in GitHub Desktop.
Save blt/1c8551fea9a37d5eb88d to your computer and use it in GitHub Desktop.
-module(udp_srv).
-export([go/1]).
%%%===================================================================
%%% API
%%%===================================================================
go(Port) ->
{ok, Socket} = gen_udp:open(Port, [binary,{active,false}]),
main(Socket).
%%%===================================================================
%%% Internal Functions
%%%===================================================================
main(Socket) ->
case gen_udp:recv(Socket, 1024) of
{ok, {_Address, _Port, Packet}} ->
io:format(user, "~p~n", [Packet]);
_ ->
ok
end,
main(Socket).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment