Douglas Wells wrote: > Second, when I look at the FTP specification, I don't find the > concept of OOB anywhere. So, it's not clear what OOB data would > mean in terms of the defined FTP commands in any case.
Steve Holde wrote: > You are correct, however, in stating that the FTP > protocol doesn't support or implement out-of-band > data transmissions. Wait a sec. RFC959 [1], on chapter 4.1.3 says: > Certain commands (such as ABOR, STAT, QUIT) may be sent over the > control connection while a data transfer is in progress. Some > servers may not be able to monitor the control and data connections > simultaneously, in which case some special action will be necessary > to get the server's attention. The following ordered format is > tentatively recommended: > 1. User system inserts the Telnet "Interrupt Process" (IP) signal > in the Telnet stream. > 2. User system sends the Telnet "Synch" signal. > 3. User system inserts the command (e.g., ABOR) in the Telnet > stream. > 4. Server PI, after receiving "IP", scans the Telnet stream for > EXACTLY ONE FTP command. I believe that the TCP "urgent" flag, activated by using socket.MSG_OOB, should be set when client must send the "Sync" signal (RFC854 [2] talks about it). I think that you do not find references of OOB in RFC959 (FTP) just because it is specified into RFC854 (Telnet). According to RFC854 a Sync signal should consist of sending Telnet DATA MARK (DM) inside a TCP packet with URGent flag set: > The Synch is sent via the TCP send operation with the Urgent > flag set and the DM as the last (or only) data octet. If we'd want to traduce this in Python we could assume that a fully RFC-compliant FTP client implementation sending 'ABOR' command should act like this: >>> import socket, telnetlib >>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) >>> s.connect(('127.0.0.1', 21)) >>> s.sendall(telnetlib.IP) >>> s.sendall(telnetlib.DM, socket.MSG_OOB) >>> s.sendall('ABOR\r\n') We also could find references about such flag ("URG"ent, alias OOB) even in Bernstein FTP-related paper (http://cr.yp.to/ftp/ pipelining.html) which says: > The client is required to send the TELNET string \377\364, and > then send the TELNET string \377\362 with the TCP Urgent bit > set, immediately before the ABOR request. ...that, traduced, should appear like this: >>> s.sendall("\377\364") # Telnet IP signal? >>> s.sendall("\377\362", socket.MSG_OOB) # Telnet Synch signal? >>> s.sendall("ABOR\r\n") I also find interesting the fact that ftplib ABOR command implementation is not RFC-compliant (and I can't realize how my server could recognize it): def abort(self): '''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.''' line = 'ABOR' + CRLF if self.debugging > 1: print '*put urgent*', self.sanitize(line) self.sock.sendall(line, MSG_OOB) resp = self.getmultiline() if resp[:3] not in ('426', '226'): raise error_proto, resp [1] http://www.faqs.org/rfcs/rfc959.html [2] http://www.faqs.org/rfcs/rfc854.html -- http://mail.python.org/mailman/listinfo/python-list