Hello, Concurrency
We’ve seen how to compile a simple module. But what about writing a concurrent program? The basic unit of concurrency in Erlang is the process. A process is a lightweight virtual machine that can communicate with other processes only by sending and receiving messages. If you want a process to do something, you send it a message and possibly wait for a reply.
The first concurrent program we’ll write is a file server. To
transfer files between two machines, we need two programs: a
client that runs on one machine and a server that runs on a
second machine. To implement this, we’ll make two modules called
afile_client and afile_server.
The File Server Process
The file server is implemented in a module called
afile_server. Just ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access