Skip to content

start the mochiweb web server

Serge edited this page Oct 1, 2021 · 3 revisions

The websocket.erl has the start_link() function just for that:

start_link() ->
    %% ... skipped
    io:format("~p: Listening at http://127.0.0.1:5001/~n",[self()]),
    mochiweb_http:start_link([
                              {name, client_access},
                              {loop, {?MODULE, http_handler, []}},
                              {port, 5001}
                             ]).

Here:

  • the port 5001 was set for the mochiweb to listen to;
  • the callback http_handler is set to deal with incoming requests.

Home       Next page