2007-06-23
echo_server
关键字: erlang,echo代码
- -module(echo_server).
- -export([start/0,stop/0]).
- -define(LISTEN_PORT,12345). % 开放端口
- -define(MAX_CONN, 5000). % 最大连接数
- start() ->
- process_flag(trap_exit, true), % 设置退出陷阱
- tcp_server:start_raw_server(?LISTEN_PORT,
- fun(Socket) -> socket_handler(Socket,self()) end,
- ?MAX_CONN,
- 0).
- %% 处理数据
- socket_handler(Socket,Controller) ->
- receive
- {tcp, Socket, Bin} ->
- gen_tcp:send(Socket, Bin); % echo
- {tcp_closed, Socket} ->
- ok;
- _ ->
- socket_handler(Socket,Controller)
- end.
- stop() ->
- tcp_server:stop(?LISTEN_PORT).
基于Joe Armstrong 的tcp_server模块来做的, 试试先 :)
编译
erl -noshell -s make all -s init stop
运行
erl -noshell -sname coderplay -s echo_server start
评论
wenew
2008-03-19
Distributed Erlang has all or nothing security [1] (so this is just too dangerous)
:erlang 用behavior来做,就没有这个问题,运行erlang的服务器不要使用root用户!
Distributed Erlang was not designed for thousands of clients
:我在http://wiki.trapexit.org/一个Non-Blocking Tcp Server上进行了简单的
stress测试,可以轻松建立15k的connections,据说可以建多达80K的connections
:erlang 用behavior来做,就没有这个问题,运行erlang的服务器不要使用root用户!
Distributed Erlang was not designed for thousands of clients
:我在http://wiki.trapexit.org/一个Non-Blocking Tcp Server上进行了简单的
stress测试,可以轻松建立15k的connections,据说可以建多达80K的connections
wenew
2008-01-24
好像你的不是一个echo server也,它只会接收,没有echo
inshua
2008-01-04
我下载了这个模块。在文档中发现一段危险的文字:
This solution does not involve distributed Erlang. Their are several reasons for this:
Distributed Erlang has all or nothing security [1] (so this is just too dangerous)
Distributed Erlang was not designed for thousands of clients
第二点很致命。博主如何看。
This solution does not involve distributed Erlang. Their are several reasons for this:
Distributed Erlang has all or nothing security [1] (so this is just too dangerous)
Distributed Erlang was not designed for thousands of clients
第二点很致命。博主如何看。
发表评论
- 浏览: 21373 次
- 性别:

- 来自: 广州

- 详细资料
搜索本博客
最新评论
-
lucene2.3.2与2.2.0建索 ...
泡坛看到有人说已经在这上面开发中文分词了吧?
-- by Arbow -
lucene2.3.2与2.2.0建索 ...
没有嘞,谢谢阿宝同学,哈哈~~ 这个看features貌似很牛的说。不过要用它还 ...
-- by coderplay -
lucene2.3.2与2.2.0建索 ...
aol同学有没有试用过 Sphinx 的索引?据说这个项目的性能比lucene高 ...
-- by Arbow -
ejabberd在linux平台的安 ...
# erl -pa /var/lib/ejabberd/ebin \ # ...
-- by wenew -
ejabberd在linux平台的安 ...
按照我的经历:outrace:需要修改你的hosts表试试。coderplay: ...
-- by eric.l






评论排行榜