开发者

Input output communication between two programs

开发者 https://www.devze.com 2022-12-18 21:52 出处:网络
I have a third party java program called kgsgtp.jar which need to communicate with my own C++ (but mainly just C) program. The documentation for the java program states:

I have a third party java program called kgsgtp.jar which need to communicate with my own C++ (but mainly just C) program. The documentation for the java program states:

=====================

You just need to make sure that stdin for kgsGtp it connected to the engine's output and stdout for kgsGtp is connected to the engine's input. Usually, the easiest way to do this is by forking and execing kgsGtp from within your engine.

=====================

Now I am a reasonably competent programmer and feel that I could probably arrange all that, given just a few more clues. I suspect that if the description was expanded to erm, 10? lines instead of three and a half then I'd have it sorted in no time.

I'm guessing that what the document means by forking, is using WinExec() or CreateProcess() in my program to execute the java program? I'm also guessing that perhaps when I use the right function, then the fact of one program's stdin corresponding to the other's stdout wil开发者_C百科l happen automatically?


That description is for unixes, where a sequence of pipe(),dup2(), fork()/exec() calls would be use to do this.

Take a look at the code snippet in the answer from denis here: How do I get console output in C++ with a Windows program? , should get you started.

Edit: more complete example is here: http://support.microsoft.com/kb/190351


What you need is equivalent of POSIX dup() on windows may be this

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号