-module(httpd_tcp_listener). -export([start_link/0]). start_link() -> Pid = spawn_link(fun init/0), {ok, Pid}. init() -> Port = 8888, Backlog = 10244, Options = [binary, inet6, % support both ipv4 and ipv6 {active, false}, {reuseaddr, true}, {backlog, Backlog} ], {ok, Listen} = gen_tcp:listen(Port, Options), accept(Listen). accept(Listen) -> case gen_tcp:accept(Listen) of {ok, Socket} -> {ok, Pid}