"Aviation and Erlang" is a presentation that I gave during BarCamp Shanghai on June 12, 2010. I talked about two fields that I am interested in and I tried to link them together. For the second part of the presentation I was showing some code examples, that are not part of the slide show itself.
2. About me
• Thomas Karsten
• Hometown: Berlin, Germany
• Current location: Shanghai, China
• Developer and scrum master at The
NetCircle
• Aviation, long distance cycling
21. 2 Erlang Server
Erlang
• Developed at Ericsson 1986
• Open source since 1998
• Distributed, fault-tolerant applications
• Processes are lightweight
• RabbitMQ, ejabberd
22. 2 Erlang Server
TCP Connection
-module(server).
-export([start/0, stop/0]).
-export([listen/0]).
listen() ->
case gen_tcp:listen(Port, ?TCP_OPTIONS) of
{ok, LSocket} ->
NewState=State#state{lsocket=LSocket},
case gen_tcp:accept(LSocket) of
{ok, Socket} ->
do_something(Socket),
{error, Reason} ->
{error, Reason}
end
{ok, NewState};
{error, Reason} ->
{stop, Reason}
end.