I did another test and added a two-second sleep
after attempting to connect to the APserver, and that removed
the problem. Thus, I conclude that the issue is that the
APserver doesn't have time to initialise before the parent tries
to connect.
I'd like to propose that APserver sends a message to the
parent instead of having an arbitrary sleep (right now it's 20
ms, I believe). There are a few different ways of doing this.
Here are a few:
- The parent redirects stdout and waits for a message from
APserver
- The same as above, but the apl session opens a named
pipe, passed in the name of the pipe to APserver and the
message is sent over that channel instead.
- APserver detaches and forks itself into the background
once all initialisation has been performed. The parent apl
session waits for the "parent" APserver to exit before
attempting to connect.
- The apl session attempts multiple retries over a few
seconds before giving up.
I'm sure there are other ways to handle it as well. At
least we know what the problem is now. :-)
Regards,
Elias