使用Twisted进行socket编程Twisted使用了更多的基于事件的方式。要写一个基本的服务器,你要实现事件处理 器,它处理诸如一个新的客户端连接、新的数据到达和客户端连接中断等情况。在Twisted中,你的事件处理器定义在一个protocol中;你也需要一 个factory,当一个新的连接到达时它能够构造这个protocol对象,但是如果你仅仅想创建一个自定义的Protocol类的实例的话
客户端综述twisted是一个设计非常灵活的框架,通过它可以写出功能强大的客户端,然而要在代码中使用非常多的层次结构。这个文档包括创建用于TCP,SSL和Unix sockets的客户端在 底层,实际上完成协议语法和处理的是Protocol类。这个类通常是来自于twisted.internet.protocol.Protocol。大 多数的protocol handlers继承自这个类或它的子类
Twisted is an event-driven networking engine in Python. It was born in the early 2000s, when the writers of networked games had few scalable and no cross-platform libraries, in any language, at their
Copyright © 2005-2024 51CTO.COM 版权所有 京ICP证060544号