[erlang-questions] What kind of objects can be a message type?
Lhfcws GMail
lhfcws@REDACTED
Fri Nov 21 08:44:21 CET 2014
Hi, I’m new to Erlang.
I have a question about the message passed among the Erlang processes.
1. I create a Socket or FileHandler, can I use ! to send it to another process and still works well?
demo code:
ListenSocket = gen_tcp:listen(1055, [{active, true}]),
Socket = gen_tcp:accept(ListenSocket),
From ! {new_socket, Socket}.
2. What if I invoking ’spawn’ to pass the Socket to the new process ?
demo code:
NewProcess = fun(Socket) -> … end.
ListenSocket = gen_tcp:listen(1055, [{active, true}]),
Socket = gen_tcp:accept(ListenSocket),
spawn(NewProcess, Socket).
=======
I know that the message in the receiver is a copy of the one in the sender, but I’m a little confused about the questions above. Could someone just explain this?
Thank you.
More information about the erlang-questions
mailing list