From: Mayne, P. <pet...@hp...> - 2009-07-01 07:50:14
|
Consider the following call taken not quite verbatim from ftplib.makeport(). (The difference is that socket.AF_INET) is actually self.af, which can be either socket.AF_INET or socket.AF_INET6.) Assume "import socket". socket.getaddrinfo(None, 0, socket.AF_INET, socket.SOCK_STREAM, 0, socket.AI_PASSIVE) CPython 2.5 returns [(2, 1, 0, '', ('0.0.0.0', 0))] Jython 2.5 returns [(2, 2, 0, 'localhost', ('127.0.0.1', 0))] The second element in the tuple is socktype: the difference reflects the different values of socket.SOCK_STREAM in the two implementations, and is of no concern. However, the canonname and particularly the sockaddr (fourth and fifth elements) in Jython are a problem. When an FTP client (using set_pasv(False)) binds a socket to sockaddr to accept the incoming data connection from the FTP server, CPython binds to sockaddr ('0.0.0.0', 0), which allows the FTP server to connect, and the FTP session continues. However, Jython binds to sockaddr ('127.0.0.1', 0). Since the socket is bound to localhost, external connection attempts from the FTP server fail: the FTP client hangs waiting for a connection to 127.0.0.1, and the FTP server fails because it can't connect to the address/port that it was told to connect to. A workaround is to make a local copy of ftplib.py and explicitly set "sa = ('0.0.0.0', 0)" before the bind(), but that probably isn't a proper fix. I've tried this on two different Windows systems and a non-Windows system. Is it possible that my systems are misconfigured? Thanks. PJDM -- Peter Mayne Hewlett-Packard Canberra, ACT, Australia |