Learning Python Networking - Second Edition
by José Manuel Ortega, Dr. M. O. Faruque Sarker, Sam Washington
Factory
The class that's responsible for creating a MessageLogger instance for each client that connects to our server is the MessageFactory class, which is an instance of twisted.internet.protocol.Factory. It is responsible for making protocols for each incoming connection.
buildProtocol is an event that will be called every time an incoming connection is found. It will assign a protocol to it. In this way, each connection will be tied to a protocol that's specified by the developer in this method. In this case, all connections will be handled through the same MessageLogger protocol, which forwards everything that's received.
We will make an instance of Factory that will be in charge of building the necessary objects. We will also specify ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access