Re: Sending messages to Erlang

Luke Gorrie <[email protected]> 09 Jan 2004 16:13:00 +0100
Newsgroups gmane.comp.lang.erlang.distel.devel
Message-ID <[email protected]>
"Vlad Dumitrescu" <[email protected]> writes:

> I have a problem with sending a message to an Erlang process from Emacs. The
> strange thing is that it used to work this morning...

Can you try this test function and see if it works (it does for me):

  (defun distel-message-send-test (node name message)
    "Send MESSAGE to the process called NAME on NODE.
  The name is resolved to a PID and then the message is sent to
  that pid (i.e. not sending directly to a registered name)."
    (interactive (list (erl-read-nodename)
                       (intern (read-string "Process name: "))
                       (read-from-minibuffer "Message: " nil nil t)))
    (erl-spawn
      (erl-send-rpc node 'erlang 'whereis (list name))
      (erl-receive ()
          ((['rex ['badrpc reason]]
            (error "whereis/1 failed: %S" reason))
           (['rex pid]
            (erl-send pid message)
            (message "Sent message."))))))

With `M-x distel-message-send-test' sending e.g. hello to rex works
for me.

Also, if the problem persists try doing this before connecting:

  (setq fsm-use-debug-buffer t)

Then you will have an *fsm-debug* buffer. If you get a nodedown again
please send the last dozen or so lines of that buffer, then we'll see
what exactly made the connection break.

> >From Erlang I send a message {self(), Msg} and the Emacs process replies to the
> received pid. The message never reaches the destination, and there is a message
> in Emacs "nodedown: emacs@vlad". At the same time, RPC calls work fine (probably
> because they send to a registered process, not a pid?)

If you have a code snippet to reproduce, please send.

> I feel it is related to the fact that the node's name is emacs@VLAD, but why
> does epmd think the name is all lowercase? What can I do? Where do I look?

Dunno, but shouldn't be a problem because hostnames aren't
case-sensitive. I think Windows sets some environment variables with
ALLCAPS while syscalls return lowercase, or something.

-Luke



-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software.
Perforce is the Fast Software Configuration Management System offering
advanced branching capabilities and atomic changes on 50+ platforms.
Free Eval! http://www.perforce.com/perforce/loadprog.html