Message4869

Author pjdm
Recipients pjdm
Date 2009-07-02.03:39:15
SpamBayes Score 9.972312e-11
Marked as misclassified No
Message-id <1246505956.64.0.512639438271.issue1391@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2009-07-02 03:39:17pjdmsetrecipients: + pjdm
2009-07-02 03:39:16pjdmsetmessageid: <1246505956.64.0.512639438271.issue1391@psf.upfronthosting.co.za>
2009-07-02 03:39:16pjdmlinkissue1391 messages
2009-07-02 03:39:15pjdmcreate