1> c(server_1).
{ok,server_1}
2>
2> Myserver=server_1:start(".").
<0.40.0>
3>
3> client_1:get_file(Myserver,"test").
{ok,<<"afdsaf\nadfasdfsad\n124234\nierweriwer\n">>}
4> client_1:list_dir(Myserver,"/").
{ok,["sys","selinux","tmp",".autofsck","root","opt","sbin",
"media",".pulse","var","dev","srv","home","bin","misc",
"mnt",".dbus","lib","etc","lost+found","proc","net",
".pulse-cookie","usr","boot"]}
5> c(client_1).
{ok,client_1}
6> client_1:list_dir(Myserver,"/usr").
{ok,["tmp","sbin","src","local","share","bin","libexec",
"lib","etc","games","java","include"]}
7>
7> client_1:ls(Myserver).
{ok,["client_1.beam","server_1.beam","1","server_1.erl",
"client_1.erl","erl_crash.dump","test",".1_server.erl.swp"]}
8> halt().
{ok,server_1}
2>
2> Myserver=server_1:start(".").
<0.40.0>
3>
3> client_1:get_file(Myserver,"test").
{ok,<<"afdsaf\nadfasdfsad\n124234\nierweriwer\n">>}
4> client_1:list_dir(Myserver,"/").
{ok,["sys","selinux","tmp",".autofsck","root","opt","sbin",
"media",".pulse","var","dev","srv","home","bin","misc",
"mnt",".dbus","lib","etc","lost+found","proc","net",
".pulse-cookie","usr","boot"]}
5> c(client_1).
{ok,client_1}
6> client_1:list_dir(Myserver,"/usr").
{ok,["tmp","sbin","src","local","share","bin","libexec",
"lib","etc","games","java","include"]}
7>
7> client_1:ls(Myserver).
{ok,["client_1.beam","server_1.beam","1","server_1.erl",
"client_1.erl","erl_crash.dump","test",".1_server.erl.swp"]}
8> halt().
server_1.erl
[deep@deep erlangstudy]$ cat server_1.erl
-module(server_1).
-export([start/1,loop/1]).
start(Dir)->spawn(server_1,loop,[Dir]).
loop(Dir)->
receive
{Client,list_dir}->
Client!{self(),file:list_dir(Dir)};
{Client,{list_dir,Mydir}}->
Client!{self(),file:list_dir(Mydir)};
{Client,{get_file,File}}->
Fullname=filename:join(Dir,File),
Client!{self(),file:read_file(Fullname)}
end,
loop(Dir).
http://www.qiyeku.com/xinwen7355834.html |
http://www.qiyeku.com/xinwen7355832.html |
http://www.qiyeku.com/xinwen7355830.html |
http://www.qiyeku.com/xinwen7355828.html |
http://www.qiyeku.com/xinwen7355826.html |
http://www.qiyeku.com/xinwen7355824.html |
http://www.qiyeku.com/xinwen7355821.html |
http://www.qiyeku.com/xinwen7355819.html |
http://www.qiyeku.com/xinwen7355817.html |
http://www.qiyeku.com/xinwen7355788.html |
http://www.qiyeku.com/xinwen7355724.html |
http://www.qiyeku.com/xinwen7355694.html |
http://www.qiyeku.com/xinwen7355689.html |
http://www.qiyeku.com/xinwen7355682.html |
http://www.qiyeku.com/xinwen7355675.html |
http://www.qiyeku.com/xinwen7355670.html |
http://www.qiyeku.com/xinwen7355660.html |
http://www.qiyeku.com/xinwen7355654.html |
http://www.qiyeku.com/xinwen7355651.html |
http://www.qiyeku.com/xinwen7355647.html |
http://www.qiyeku.com/xinwen7355645.html |
http://www.qiyeku.com/xinwen7355642.html |
http://www.qiyeku.com/xinwen7355639.html |
http://www.qiyeku.com/xinwen7355635.html |
http://www.qiyeku.com/xinwen7355580.html |
http://www.qiyeku.com/xinwen7355576.html |
http://www.qiyeku.com/xinwen7355552.html |
http://www.qiyeku.com/xinwen7355534.html |
http://www.qiyeku.com/xinwen7355526.html |
http://www.qiyeku.com/xinwen7355475.html |