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 |
From: Alan K. <jyt...@xh...> - 2009-07-01 14:38:37
|
[Peter] > 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”. Hi Peter, I'm currently attending Europython at the moment. I promise I'll look at this in detail soon, either during the sprints at the end of the week, or when I return home at the weekend. Meantime, it would be good if you record a bug for this in the bug database. http://bugs.jython.org Regards, Alan. |
From: Mayne, P. <pet...@hp...> - 2009-07-02 03:40:50
|
Done: issue 1391. (There's no 2.5.0 in the "Versions" list.) PJDM -- Peter Mayne Hewlett-Packard Canberra, ACT, Australia -----Original Message----- From: ala...@gm... [mailto:ala...@gm...] On Behalf Of Alan Kennedy Sent: Thursday, 2 July 2009 12:34 AM To: Mayne, Peter Cc: jyt...@li... Subject: Re: [Jython-users] socket.getaddrinfo() breaks ftplib FTP client [Peter] > 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". Hi Peter, I'm currently attending Europython at the moment. I promise I'll look at this in detail soon, either during the sprints at the end of the week, or when I return home at the weekend. Meantime, it would be good if you record a bug for this in the bug database. http://bugs.jython.org Regards, Alan. |