Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

42 lines (34 sloc) 0.901 kb
%% @author Bob Ippolito <bob@mochimedia.com>
%% @copyright 2007 Mochi Media, Inc.
%% @doc Simple and stupid echo server to demo mochiweb_socket_server.
-module(mochiweb_echo).
-author('bob@mochimedia.com').
-export([start/0, stop/0, loop/1]).
stop() ->
mochiweb_socket_server:stop(?MODULE).
start() ->
mochiweb_socket_server:start([{link, false} | options()]).
options() ->
[{name, ?MODULE},
{port, 6789},
{ip, "127.0.0.1"},
{max, 1},
{loop, {?MODULE, loop}}].
loop(Socket) ->
case mochiweb_socket:recv(Socket, 0, 30000) of
{ok, Data} ->
case mochiweb_socket:send(Socket, Data) of
ok ->
loop(Socket);
_ ->
exit(normal)
end;
_Other ->
exit(normal)
end.
%%
%% Tests
%%
-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").
-endif.
Jump to Line
Something went wrong with that request. Please try again.