Skip to content

Instantly share code, notes, and snippets.

@suncle1993
Created August 30, 2018 07:43
Show Gist options
  • Save suncle1993/9de5b6289be78c339928ee8ffefce501 to your computer and use it in GitHub Desktop.
Save suncle1993/9de5b6289be78c339928ee8ffefce501 to your computer and use it in GitHub Desktop.
erlang print_server
%%%-------------------------------------------------------------------
%%% @author Suncle
%%% @doc
%%% print_server
%%% @end
%%% Created : 2017/12/18 14:53
%%%-------------------------------------------------------------------
-module(print_server).
-author("Suncle").
%% API
-export([print_server/0, start_print_server/0, send_msg/2]).
print_server() ->
receive
Msg ->
io:format("print_server received msg: ~p~n", [Msg]),
print_server()
end.
start_print_server() ->
Pid = spawn(?MODULE, print_server, []),
Pid.
send_msg(Msg, Pid) ->
Pid ! Msg,
io:format("send_normal_msg: ~p~n", [Msg]).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment