Martti Malmi 通信

回复:Bitcoin API 研究进展

中本聪 · 2010 年 2 月 5 日

SN-10144 附来源、原文与上下文。

阅读语言

我在 wxSocketServer::Accept(bool wait = true) 的文档中注意到这段:

I noticed this in the docs for wxSocketServer::Accept(bool wait = true):

文档引文wxWidgets 文档来源 ↗

“如果 wait 为 true,且没有待接受的连接,它会等待下一个入站连接到达。**警告:这会阻塞 GUI。”

"If wait is true and there are no pending connections to be accepted, it will wait for the next incoming connection to arrive. **Warning: This will block the GUI."

wxWidgets 对单线程的要求简直到了病态的程度。不仅要求单线程,还必须是 GUI 线程。连 wxStandardPaths 这么与界面无关的东西,我都栽了跟头。这些对界面代码倒没问题,因为 Windows 本来也施加同样的限制;但对于没有界面的服务器守护进程代码,wx 调用就不可靠了。

wxWidgets is pathologically single-threaded. Not only single-threaded, but must-be-the-GUI-thread-ed. Even for something as non-UI as wxStandardPaths I got nailed. All this is fine for UI code, since this is the same constraint placed by Windows anyway, but for UI-less server daemon code, wx calls are uncertain.

我目前的研究进展:

Status of my research currently:

要让 PHP、Python 等访问服务器,我们需要使用普通套接字。我想,可以只绑定 localhost,让它只能通过回环接口访问,从而限制为本机使用。他们说,简单检查收到的连接的 IP,断开所有不是 127.0.0.1 的连接,也同样严密。不妨两种都做。

For PHP, Python, etc to access the server, we need to use regular sockets. I think we can make it local-only by binding to localhost only, so it can only be accessed through the loopback. They say it's also watertight to simply check the IP of connections received and disconnect anything not 127.0.0.1. May as well do both.

XML-RPC 有点臃肿。C++ 有 4 个库,但都很大,难以构建,还有依赖和许可证问题。一些发帖者抱怨,所有 C++ 和 PHP 的 XML-RPC 库都有很多错误。

XML-RPC is a bit fat. There are 4 libraries for C++ but they're all big and hard to build, dependencies, license issues. Some posters complain all the C++ and PHP XML-RPC libraries are buggy.

JSON-RPC 是一种更简单、更优雅的标准。它足够简单,我可以使用通用 JSON 解析器。

JSON-RPC is a simpler more elegant standard. It's simple enough I could use a generic JSON parser.

PHP、Python 和 Java 都有不错的 JSON-RPC 实现。

PHP, Python and Java all have good implementations of JSON-RPC.

我目前倾向于 JSON-RPC。

I'm currently leaning towards JSON-RPC.

来源

阅读字号

选择适合你的字号,之后阅读会继续使用。