diff options
author | Joe Zhao <ztuowen@gmail.com> | 2014-05-16 20:16:33 +0800 |
---|---|---|
committer | Joe Zhao <ztuowen@gmail.com> | 2014-05-16 20:16:33 +0800 |
commit | 859179718904a1824082fdbbf77192bd1ce762e7 (patch) | |
tree | 2869db33b8c21416676d6fc01eb65a079c318f83 /startserv.erl | |
download | local-859179718904a1824082fdbbf77192bd1ce762e7.tar.gz local-859179718904a1824082fdbbf77192bd1ce762e7.tar.bz2 local-859179718904a1824082fdbbf77192bd1ce762e7.zip |
First commit
Diffstat (limited to 'startserv.erl')
-rw-r--r-- | startserv.erl | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/startserv.erl b/startserv.erl new file mode 100644 index 0000000..2f583a4 --- /dev/null +++ b/startserv.erl @@ -0,0 +1,43 @@ +%%%------------------------------------------------------------------- +%%% @author Joe Zhao +%%% @copyright (C) 2014, <COMPANY> +%%% @doc +%%% +%%% @end +%%% Created : 26. 四月 2014 16:34 +%%%------------------------------------------------------------------- +-module(startserv). +-author("Joe Zhao"). + +-compile([debug_info]). + +%% API +-export([start/0,startmon/0,mon/0]). + +mon() -> + process_flag(trap_exit,true), + Pid = spawn_link(tcpport,start,[5575]), + receive + {_,shutdown} -> Pid ! shutdown; + {'EXIT',Pid,normal} -> ok; + {'EXIT',Pid,shutdown} -> ok; + {'EXIT',Pid,_} -> mon() + end. + +startmon() -> + spawn(?MODULE,mon,[]). + +start() -> + PPid=startmon(), + timer:sleep(100), + Pid=portman:start({"localhost",5575}), + portman:send(Pid,["Something 1"]), + timer:sleep(100), + portman:send(Pid,["Something 2"]), + timer:sleep(100), + portman:send(Pid,["Something 3"]), + timer:sleep(100), + portman:send(Pid,["Something 4"]), + timer:sleep(100), + portman:send(Pid,shutdown), + PPid ! {self(),shutdown}. |