Twisted:带有推送生产者示例的 tcp 服务器?
我想使用 Python 和 Twisted 组合简单的 TCP 服务器。
服务器启动并等待连接 - 我已经有客户端 - 非 python 应用程序。一旦建立连接,服务器就会开始以一定的间隔(例如1秒)发送数据。
服务器从静态文件读取数据(一次一条记录),我应该能够弄清楚这部分。
我假设一旦客户端连接,我将使用推送生成器开始推送数据。
我有一个简单的tcp服务器,工厂是twisted,我可以对connectionMade/dataReceived等做出反应,但我不知道如何插入推送生产者。
有人知道在twisted中显示带有tcp服务器的推送生产者的示例吗?
I want to put together simple TCP server using Python and Twisted.
The server starts up and waits for connection - I already have client - non-python application. Once connection is made server starts sending data at some interval (e.g. 1 sec).
The server reads data from a static file (a record at a time), I should be able to figure out this part.
I assume that I would use push producer to start pushing data once client is connected.
I have simple tcp server with factory in twisted and I can react to connectionMade/dataReceived and so on but I can't figure out how to plug in the push producer.
Anyone knows any examples showing push producer with tcp server in twisted?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这里是推送生成器的完整示例。它已被添加到twisted svn 中作为示例。
Here is a complete example of a push producer. It's been added to the twisted svn as an example.
一些简单的事情怎么样:
这有硬编码的数据,但你说从文件中读取它不是你的问题。如果您能告诉我们这个过于简单的“推送服务器”有什么问题,也许我们可以提供更好的帮助!-)
What about something simplistic like:
This has hard-coded data, but you say that reading it from a file instead is not your problem. If you can tell us what's wrong with this overly simplistic "push server", maybe we can offer better help!-)