0 votes

I launch an executable lib with OS.execute. I want to know how to send and read commands to that subprocess. Thanks.

in Engine by (14 points)

1 Answer

+1 vote

It seems that OS.execute has an optional output parameter that can be used to get the output of the command. I have not managed to make it working though. You can see here how this is implemented "under the hood".

It also appears that there are not support for inter process communications (such as shared memory or pipes) between Godot and other processes in the OS. Even if there was support, I am not sure it would have been portable.

One way to overcome this is to use PacketPeerUDP or StreamPeerTCP to send and receive commands to the other process.
Even though both processes are on the same machine, it is a valid approach. Use localhost as the address to which send the packets.

by (262 points)

The thing is to use PacketPeerUDP I need to have sever and client sides. But in my case all I want is to execute a chess engine as executable in another process and then communicate with it. With OS.execute I manage to get only the first output of the engine. I want to keep the connection with the process.

How do you normally communicate with the engine?
If you can not modify ithe engine to use UDP/TCP, maybe you can write a wrapper program that would receive packets from Godot and communicate with the chess engine and vice versa.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.