summaryrefslogtreecommitdiffstats
path: root/Lib/ftplib.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/ftplib.py')
-rw-r--r--Lib/ftplib.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/ftplib.py b/Lib/ftplib.py
index 1b4705e..cc96a34 100644
--- a/Lib/ftplib.py
+++ b/Lib/ftplib.py
@@ -32,6 +32,10 @@ import socket
import string
+# Magic number from <socket.h>
+MSG_OOB = 0x1 # Process data out of band
+
+
# The standard FTP server control port
FTP_PORT = 21
@@ -53,6 +57,10 @@ all_errors = (error_reply, error_temp, error_perm, error_proto, \
CRLF = '\r\n'
+# Telnet special characters
+DM = chr(242) # Data Mark
+IP = chr(244) # Interrupt Process
+
# Next port to be used by makeport(), with PORT_OFFSET added
# (This is now only used when the python interpreter doesn't support
# the getsockname() method yet)
@@ -152,6 +160,18 @@ class FTP:
if resp[0] <> '2':
raise error_reply, resp
+ # Abort a file transfer. Uses out-of-band data.
+ # This does not follow the procedure from the RFC to send Telnet
+ # IP and Synch; that doesn't seem to work with the servers I've
+ # tried. Instead, just send the ABOR command as OOB data.
+ def abort(self):
+ line = 'ABOR' + CRLF
+ if self.debugging > 1: print '*put urgent*', `line`
+ self.sock.send(line, MSG_OOB)
+ resp = self.getmultiline()
+ if resp[:3] not in ('426', '226'):
+ raise error_proto, resp
+
# Send a command and return the response
def sendcmd(self, cmd):
self.putcmd(cmd)