Receive block not printing message

I have two tabs open in my terminal, both of which have iex running on them. I know running self on both the tabs would print their pid which returns the same pid.

In my tab1, I ran

receive do
 message -> IO.puts message

Since there are no messages in the mailbox, it keeps waiting for the new one to come. Please correct me if I am wrong here.

So the tab1 is waiting for a message to come and in my tab 2, I run

send(self, "Hello world")

Going back to tab1, I dont see it printing the message in the terminal. How ? and Why?

Starting iex in 2 shells is like starting two VM… If You want them to communicate, You need to manage distribution.

You might try some examples here


Hmm, and I guess the PID is same for both the tab is because they are not os process but BEAM process?

Yes, they are not OS processes…