我如何通过Python中的服务器套接字重复发送消息?
如标题,我想知道如何重复发送消息。
就像使用“while”函数一样简单吗?
我想做的是,每当有客户加入时。我想让服务器端,不断地向客户端发送数据。如果可能的话,有一种方法可以调整我希望多久发送下一条消息。
任何帮助将不胜感激,谢谢。
Like the title, i would like to know how to send messages repeatedly.
Is it as simple as using a "while" function?
What I'm trying to do is, when ever a client joins. I would like to have the server end, constantly send the data to the client. And if possible a way to adjust how soon i want the next message sent out.
Any help would be appreciated, thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
而不是做
Do
Instead of doing
Do
了解 SocketServer 模块,特别是 ThreadingMixIn 允许您处理多个客户端 同时地。它是一个Python库,可以阅读SocketServer.py源文件来了解它是如何实现的。
Read about the SocketServer module, in particular the ThreadingMixIn to allow you to handle multiple clients simultaneously. It is a Python library, and the SocketServer.py source file can be read to see how it is implemented.