I'm writing an mini FTP server in Python that exposes an underlying database as if it was FTP. The flow is something like this:
sock.send("150 Here's the file you wanted\r\n")
proc = Popen2(...)
for parts in data:
data_sock.send(parts)
proc.kill()
sock.send("226 There's the file you wanted\r\n")
data_sock.shutdown(0)
data_sock.close()
data_sock is the PASV socket that's up and working, confirmed by Wireshark. What's actually happening is after the 163,328th byte has been sent over the data_sock, the data_sock.send() line just hangs. I suspect the send buffer is full, but it's a mystery to me why the FTP clients wouldn't be reading from the PASV socket.
I've included the Popen2(...) line because I've managed to reproduce http://bugs.python.org/issue3006 on OS X--sockets don't close until the Popen process is killed. Not sure if this is somehow related.