简体   繁体   English

Python / Twisted-服务器还是客户端?

[英]Python/Twisted - Server also a client?

Basically, I have a twisted server accepting data from clients, which works great. 基本上,我有一台扭曲的服务器,它从客户端接收数据,效果很好。 What I'd like this server to do is send certain received data to another server, which will then echo it to everything connected to it(essentially sharing data between multiple servers using a central hub.) So as a simple idea: 我希望该服务器执行的操作是将某些接收到的数据发送到另一台服务器,然后再将其回显到与其连接的所有设备(实际上是使用中央集线器在多个服务器之间共享数据。)因此,一个简单的想法是:

Data -> Server1 -> Central Server -> Connected clients(Server1, Server2, Server3, etc;) 数据-> Server1->中央服务器->已连接的客户端(Server1,Server2,Server3等;)

Any ideas on how this could be achieved? 关于如何实现的任何想法? I've been told calling 有人告诉我打电话

reactor.connect(host, port)

inside the server function will create a client, but how can I share the data between the server and the client? 服务器功能内部将创建一个客户端,但是如何在服务器和客户端之间共享数据? Is there a way to call the clients sendLine from within the servers dataReceived? 有没有办法从服务器dataReceived内调用客户端sendLine?

看看如何在Twisted中实现代理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM