Skip to content

Instantly share code, notes, and snippets.

@blt blt/udp_srv.erl
Created Apr 3, 2015

Embed
What would you like to do?
-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
You can’t perform that action at this time.