Skip to content

Commit

Permalink
Echo process with IO.write compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
algogrit committed Mar 20, 2024
1 parent bd177b4 commit 2a857b0
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions examples/07-processes/echo.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
defmodule Echo do
def start do
{:ok, echo_pid} = Task.start fn -> loop() end
Process.register(echo_pid, :echo)
echo_pid
end

def loop do
receive do
{:io_request, caller, reply_as, msg} ->
IO.inspect msg
send(caller, {:io_reply, reply_as, msg})
loop()
msg ->
IO.inspect msg
loop()
end
end
end

Echo.start
# IO.write(:echo, "hello")

0 comments on commit 2a857b0

Please sign in to comment.