Python和C之间的独立于操作系统的计划间通信 [英] OS-independent Inter-program communication between Python and C

查看:149
本文介绍了Python和C之间的独立于操作系统的计划间通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很少知道我在这里做什么,我从来没有做过这样的事,但我和一个朋友正在写竞争象棋程序,他们需要能够传达​​给对方。

I have very little idea what I'm doing here, I've never done anything like this before, but a friend and I are writing competing chess programs and they need to be able to communicate to each other.

他会主要C语言编写,我的大部分将在Python中,我可以看到几个选项:

He'll be writing mainly in C, the bulk of mine will be in Python, and I can see a few options:


  • 或者写入到一个临时文件或连续的临时文件。作为通信将不以任何方式笨重,这可能工作,但似乎是一个丑陋的解决方法对我来说,程序将不得不继续检查变更/新文件,它只是似乎难看。

  • 找到操纵管道即mine.py的一些方法| ./his。这似乎是一个有点钻牛角尖的。

  • 使用插座。但我不知道我会做,所以可能有人给我一个指针,一些阅读材料?我不知道是否有独立于操作系统的,与语言无关的方法。会有必须是某种主管服务器程序来管理?

  • 使用某种HTML协议,这似乎有点小题大做的。我不介意在同一台计算机上运行的程序。

什么人建议,和我在哪里可以开始阅读?

What do people recommend, and where can I start reading?

推荐答案

如果你想要和需要真正独立于操作系统,独立于语言的进程间通信,插座可能是最好的选择。

If you want and need truly OS independent, language independent inter process communication, sockets are probably the best option.

这将使两个程序在计算机之间进行通信,以及(不包括code的变化)。

This will allow the two programs to communicate across machines, as well (without code changes).

有关阅读材料,这里有一个 Python的socket编程如何的。

For reading material, here's a Python Socket Programming How To.

这篇关于Python和C之间的独立于操作系统的计划间通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆