Failed to establish passive FTP connection.

I am creating ftp client and I have a problem.

First, I create a socket to which I sent USER and PASS, then PASV received IP and PORT, and then created a second data socket and tried to connect, but there is a problem.

It will connect 5 times to 6, but for the sixth time I got an error 111 Connection Refused, and I have no idea how to fix it.

0
source share
1 answer

The response text PASVdoes not have a standardized format ( EPSVhowever), so make sure you parse IP / Port correctly, as you can get one of many different formats used by real-world servers:

227 Entering Passive Mode (h1,h2,h3,h4,p1,p2).
227 Entering Passive Mode (h1,h2,h3,h4,p1,p2
227 Entering Passive Mode. h1,h2,h3,h4,p1,p2
227 =h1,h2,h3,h4,p1,p2

.

IP/Port , IP/Port, , IP/ /, , IP/Port.

, connection refused , , , ABOR, IP/ PASV, IP/.

0

All Articles