18 lines
280 B
Elixir
18 lines
280 B
Elixir
|
defmodule Server do
|
||
|
def start(addr) do
|
||
|
accept_loop(addr)
|
||
|
end
|
||
|
|
||
|
defp accept_loop(addr) do
|
||
|
case :gen_tcp.accept(addr) do
|
||
|
{:ok, socket} ->
|
||
|
accept(socket)
|
||
|
end
|
||
|
accept_loop(addr)
|
||
|
end
|
||
|
|
||
|
defp accept(socket) do
|
||
|
send(Server.Conn, socket)
|
||
|
end
|
||
|
end
|