我可以使用哪些编程语言来编写 Bonjour 软件?
我真的受到编程语言的限制吗?我可以想象,要使用 Bonjour,我需要拥有任何语言都无法使用的特殊库。那么,我需要使用那些有相应库的语言。作为第二个选项,我可以想象,Bonjour 提供了一个几乎可以被任何语言使用的界面(例如 Bonjour 将信息保存在特殊文件或环境变量中,并且我可以使用大多数语言来访问此信息) 。
PS 我对 PHP 特别感兴趣。
Am I really restricted by programming languages? I can imagine that, to use Bonjour, I need to have special libraries which could be not available for any language. So, then I need to use those languages which have corresponding libraries. As the second option, I can imagine, that Bonjour provide an interface which can be used almost by any language (for example Bonjour saves information in a special file or in environment variables and than I can use most of the languages to access this information).
P.S. I have a particular interest in PHP.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
许多语言都有 ZeroConf 绑定,包括 Java 和 .Net,并且有一个在 Python 中使用它的示例 此处。它使用 D-Bus 与守护进程对话。 D-Bus 的绑定列表包括 PHP、Python、Perl、Java、. Net、C++、Haskell、OCaml、Squeak 等等。甚至还有 Pascal 绑定!
所以不,你不会受到编程语言的很大限制。
Plenty of languages have ZeroConf bindings, including Java and .Net, and there's an example of using it in Python here. It uses D-Bus to talk to the daeomon. This list of bindings for D-Bus includes PHP, Python, Perl, Java, .Net, C++, Haskell, OCaml, Squeak, and plenty more besides. There's even a Pascal binding!
So no, you are not very restricted by programming languages.
搜索“ZeroConf”(实际协议的名称)而不是“Bonjour”(Apple 协议的具体实现)会更好。
You will have better luck searching for "ZeroConf", which is the name of the actual protocol, rather than "Bonjour", which is Apple's specific implementation of the protocol.
Apple 的 Bonjour for Windows SDK 作为 COM 组件安装,可以调用从 PHP 通过 COM 函数。
多种语言的示例代码随 SDK 一起安装。虽然 PHP 不是其中之一,但这些示例应该是可读的。
有关 API 的另一个信息来源是 Bonjour 文档< Mac OS X 参考库中的 /a>。
Apple's Bonjour for Windows SDK is installed as a COM component, which can be called from PHP via the COM functions.
Sample code in several languages is installed with the SDK. While PHP is not one of them, the examples should be readable.
Another source of information on the API is the Bonjour documentation in the Mac OS X reference Library.
Roman,由于您对 PHP 特别感兴趣,您可以查看 php5-avahi 扩展:
http://code.google.com/p/php5-avahi/
我'我还没有使用它(刚刚开始为自己研究同样的问题),但它看起来像你正在寻找的:一种用 PHP 编写 Bonjour(又名,Avahi,Zeroconf,Rendevous,mDNS)消息/广播/消费的方法。
遗憾的是,它看起来像是一个相当停滞的项目(4 次提交,全部发生在 2009 年)。但希望它能帮助您入门。
希望有帮助,
本杰明
Roman, since you're particularly interested in PHP, you might checkout the php5-avahi extension:
http://code.google.com/p/php5-avahi/
I've not used it yet (just begun researching this same question for myself), but it looks like what you're looking for: a way to write Bonjour (aka, Avahi, Zeroconf, Rendevous, mDNS) messaging/broadcasting/consuming in PHP.
Sadly, it looks like a fairly stagnant project (4 commits, all in 2009). Hopefully, though, it will help get you started.
Hope that helps,
Benjamin