0

I am trying to write a dynamic module for zeromq. It works when I test it in batch mode, but not interactively. The layout of the test is that I run a server (https://github.com/jkitchin/emacs-modules/blob/master/zeromq/hwserver.c) that just returns the string "World" for every request. This works.

The module defines a function https://github.com/jkitchin/emacs-modules/blob/master/zeromq/mod-zmq.c that is registered in Emacs as zmq-send-and-recv which takes one string argument, sends it to the server, and gets a request. I can see that the argument is sent to the server correctly, and when I test it in a batch mode (eg make test in https://github.com/jkitchin/emacs-modules/blob/master/zeromq/makefile), it appears to get the response back correctly too.

But If I try to run this interactively from emacs, e.g the first source block in https://github.com/jkitchin/emacs-modules/blob/master/zeromq/zeromq.org, or running the code in https://github.com/jkitchin/emacs-modules/blob/master/zeromq/test.el the msg is sent to the server but I get empty strings back in Emacs.

I can't figure out any reason for this and wondered if anyone has any ideas on debugging it.

John Kitchin
  • 11,555
  • 1
  • 19
  • 41
  • I played a bit around with it and noticed that `zmq_recv` occasionally returns -1, meaning some error happened. The fact that it doesn't happen in batch mode is probablly due to different timing behaviour. – politza Jul 11 '17 at 20:11
  • Indeed, that is it. If I wrap it in a while loop that repeats until the return is not -1, it works both ways. Thanks for the tip. – John Kitchin Jul 11 '17 at 20:39

0 Answers0