Specifically for Twisted, I would like to be able to determine whether the server I am connected to supports active or passive mode. See API.
If somebody could explain or give example in FTP protocol how you can determine whether the server supports active or passive modes.
Passive mode is enabled by issuing the
PASVcommand to the server. If it responds with an error code (should be500 Unknown command) upon issuing that command, then you know that it is not supported. If it responds with a227 Entering Passive Mode, then you know that passive is supported.Example using command line telnet and FTP commands:
Good command (passive mode is supported):
Bad command (500 error thrown):