Index: twisted/internet/abstract.py =================================================================== --- twisted/internet/abstract.py (revision 10698) +++ twisted/internet/abstract.py (working copy) @@ -25,7 +25,7 @@ import types, string # Twisted Imports -from twisted.python import log, reflect +from twisted.python import failure, log, reflect from twisted.persisted import styles # Sibling Imports @@ -183,6 +183,19 @@ self.startWriting() self.disconnecting = 1 + def abortConnection(self): + """Close the connection immediately. + + Call this to cause this FileDescriptor to lose its connection immediately; + the contents of the write buffer are discarded. + """ + + if self.connected: + self.stopReading() + self.stopWriting() + self.disconnecting = 1 + self.connectionLost(failure.Failure(main.CONNECTION_ABORTED)) + def stopReading(self): """Stop waiting for read availability. Index: twisted/internet/main.py =================================================================== --- twisted/internet/main.py (revision 10698) +++ twisted/internet/main.py (working copy) @@ -40,6 +40,7 @@ CONNECTION_DONE = error.ConnectionDone('Connection done') CONNECTION_LOST = error.ConnectionLost('Connection lost') +CONNECTION_ABORTED = error.ConnectionAborted('Connection aborted') running = None Index: twisted/internet/error.py =================================================================== --- twisted/internet/error.py (revision 10698) +++ twisted/internet/error.py (working copy) @@ -189,6 +189,10 @@ return s +class ConnectionAborted(ConnectionLost): + """Connection was aborted""" + + class ConnectionFdescWentAway(ConnectionLost): """Uh""" #TODO