It's a TCP server framework written in Erlang. It mimics some web frameworks, featuring middleware etc.
-
TCP streams are packed into messages for you. You can focus on processing network messages, and leave the receive & send & other messy socket stuff to the framework.
-
It works in a one-erlang-process-per-client style, maximizing throughput and concurrency, yet communication between processes is still easy.
-
It elaboratively supports a login stage for every connection. And the login stage is cleanly separated with normal network operations.
-
It also has middleware support. You can easily transform your network messages, or serialize model objects, however you like, in the middleware, and keep your business code clean.
-
The framework itself is dead simple.
In your Erlang node, make sure the application carthage
is started, and
then:
carthage:start({LoginHandler, LoginOpts},
{ClientHandler, ClientOpts},
{Middlewares, Env},
ListenPort, NumAcceptors)
-
LoginHandler
andClientHandler
: Your handler modules for login stage and normal operations, accordingly. -
LoginOpts
andClientOpts
: Configurations for your handler modules. Must be proplists. -
Middlewares
: List of middleware modules. -
Env
: Environment settings. Can be accessed by all handlers and middlewares. Must be proplists. -
ListenPort
: TCP port to listen on. -
NumAcceptors
: Size of the acceptor pool.
If the start
function returned successfully, you'll have a running
carthage instance.
For examples, see demo/*.erl
.
The MIT License: http://l04m33.mit-license.org/