I have these 2 Erlang modules:
Server:
-module(server).
-export([start/0, loop/0]).
books(Cc) ->
string:concat("Works ", Cc).
loans(Name) ->
string:concat("Works too ", Name).
loop() ->
receive
{ClientPID, books, Info} ->
ClientPID ! books(Info),
loop();
{ClientPID, loans, Info} ->
ClientPID ! loans(Info),
loop();
_ ->
io:fwrite("Invalid request received!~n"),
loop()
end.
start() ->
spawn(server, loop, []).
and Client:
-module(client).
-export([start/1, client/1]).
start(Server_Address) ->
spawn(client, client, [Server_Address]).
client(Server_Address) ->
Server_Address ! {self(), books, "potato"},
receive
Response ->
io:format("CLIENT ~w: ~w~n", [self(), Response])
end.
I call Pid = server:start() it gives me a correct Pid without any errors, but when I call either client:start(Pid) or client:client(Pid) in a different Eshell it just doesn't communicate(It works if called in the same Eshell, obviously).
I know I'm just doing something wrong, but what is it? Thanks