Chat Server in Erlang (13 May 2005)
This is my first project in
Erlang. I'm enjoying learning the
language very much. It is well suited to programs that have many
concurrent processes, like servers. Erlang was created by
Ericsson. They did an excellent job
in designing the language and platform.
This chat server is divided into nine modules:
-
chat contains code to start and stop the application
-
chat_acceptor accepts incoming tcp connections and creates
liason processes to handle them
-
chat_acceptor_sup supervises the acceptor
-
chat_dispatcher keeps a list of active liasons and dispatches
messages to them
-
chat_liason communicates with a client and sends messages to
the dispatcher
-
chat_liason_sup supervises all of the liasons
-
chat_logger keeps a log file of chat server events and system
errors
-
chat_report_handler plugs into the Erlang system logger and
forwards error reports to chat_logger
-
chat_supervisor is the root of the application
supervision tree. It supervises the logger, liason supervisor,
dispatcher, and acceptor supervisor
The chat server is an Erlang OTP application. It is started with the
command application:start(chat). Various server parameters are defined
in the application definition file, ebin/chat.app. The logfile is created
in the priv directory.
The protocol consists of lines of text terminated by CRLF.
Here is the transcript of a telnet session:
Welcome to Unnamed Chat Server
1118308610 localhost:1273 connected.
Hello!
1118308613 <localhost:1273> Hello!
Goodbye...
1118308619 <localhost:1273> Goodbye...
|
Downloads
The files are provided for educational purposes only.
|
Copyright © 1999-2007 Michael Leonhard
|
|
|