When you first call reactor.listen
on your protocol factory, it returns an object that implements IListeningPort
, see http://twistedmatrix.com/documents/8.2.0/api/twisted.internet.interfaces.IListeningPort.html -- just save that object somewhere and when you want to stop listening on that protocol factori, call that object's stopListening
method.
I assume that reactor.listen
on the protocol factory is what you implicitly mean by "registering" a protocol (which logically should be what you're trying to undo by "unregistering" it), if you mean something else please clarify exactly how you "register a protocol" and we'll work out how to undo that!-)