Created
April 3, 2015 20:48
-
-
Save blt/1c8551fea9a37d5eb88d 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
-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