OpenTCPstream FTP Server PROFTPD Problem

Archives Forums/BlitzPlus Bug Reports/OpenTCPstream FTP Server PROFTPD Problem

Garfield(Posted 2010) [#1]
After changing my webhost from a Windows IIS with Microsoft FTP Server to a Apache Server with PROFTPD FTP Server my BlitzPlus Code wont work. It hangs on the second OpenTCPStream Command in the code:

way = OpenTCPStream("93.188.xxx.xxx",port)


tcp=OpenTCPStream( "93.188.xxx.xxx",21 ) 


If Not tcp AddTextAreaText daten, "Failed.":Return

AddTextAreaText daten,ReadLine$( tcp )+ Chr$(10)


Delay 1950
WriteLine tcp,"USER admin4" 

AddTextAreaText daten,ReadLine$( tcp )+ Chr$(10)


Delay 1950
WriteLine tcp,"PASS xxxxxxxxx" 

Linetext$=ReadLine$( tcp )

If Left$(linetext$,3) = "530" Then AddTextAreaText daten,"Command 530"+ Chr$(10):Return False
Delay 1950
AddTextAreaText daten,Linetext$+ " OK"+ Chr$(10)


WriteLine tcp,"PASV"

Repeat 
	pro$ = ReadLine(tcp) 
	AddTextAreaText daten, pro$ + Chr$(10)
	;
Until Left$(pro$,3)="227"  
mail$ = pro$  
;----------------------------------------------------
; calculating the port
in = Instr(mail$,"(")+1  
adr$ = Mid$(mail$,in,loc_of_xth(mail$,4,",")-in)  
servip$ = Replace$(adr$,",",".") 
	AddTextAreaText daten,"Server IP: " + servip$ + Chr$(10)
beh$ = Right$(mail$,Len(mail$)-(loc_of_xth(mail$,4,","))) 
faktor1 = Int(Left$(beh$,Instr(beh$,",")-1)) 
faktor2 = Int(Mid$(beh$,Instr(beh$,",")+1,Instr(beh$,")")-Instr(beh$,","))) 
AddTextAreaText daten,faktor1 + Chr$(10)
AddTextAreaText daten,faktor2 + Chr$(10)
port = faktor1*256 + faktor2 
AddTextAreaText daten,"port: "+port + Chr$(10)
;-------------------------------------------------
;Delay 1950
;way = OpenTCPStream("93.188.xxx.xxx",port)
WriteLine tcp,"SYST"
AddTextAreaText daten,ReadLine$( tcp )+ Chr$(10)

;Delay 1950
way = OpenTCPStream("93.188.xxx.xxx",port)


If Not way AddTextAreaText daten "Could´nt find the way....................." + Chr$(10) + Chr$(10)


with the Microsoft FTP Server everything works well, but now the way -Stream could´nt get, way is always "0"

A standard FTP programm like Ipswitch´s WS_FTP works fine with this new server.

I´ve logged the data and this is what I got:

with WS_FTP
 

   FTP   Response: 227 Entering Passive Mode (93,188,xxx,xxx,160,79). 
Request:   TCP   41039 > 62300 [SYN, ACK] Seq=0 Ack=1 Win=5840 Len=0 MSS=1452 WS=7 
Response:   TCP   62300 > 41039 [ACK] Seq=1 Ack=1 Win=66792 Len=0


with BlitzPlus and the PROFTPD Server:

   FTP   Response: 227 Entering Passive Mode (93,188,xxx,xxx,163,128). 
Request:   TCP   61573 > 41856 [SYN] Seq=0 Win=8192 Len=0 MSS=1460 WS=2 
Request:   TCP   61571 > ftp [ACK] Seq=35 Ack=170 Win=66620 Len=0 
Request:   TCP   61573 > 41856 [SYN] Seq=0 Win=8192 Len=0 MSS=1460 WS=2 
Request:   TCP   61573 > 41856 [SYN] Seq=0 Win=8192 Len=0 MSS=1460 

4 Requests but no answer!


with Blitzbasic Programm and Microsoft FTP Server:
the data port is automaticely named as: netview-aix
 

   FTP   Response: 227 Entering Passive Mode (80,152,xx,xx,6,125) 
Request:   TCP   61888 > netview-aix-1 [SYN] Seq=0 Win=8192 Len=0 MSS=1460 WS=2 
Antwort:    TCP   netview-aix-1 > 61888 [SYN, ACK] Seq=0 Ack=1 Win=16384 Len=0 MSS=1452 WS=0 
Request:   TCP   61888 > netview-aix-1 [ACK] Seq=1 Ack=1 Win=66792 Len=0

got an answer and it works!

I´ve checked it on Windows 7 and XP
BlitzPlus 1.47

Any idea?


Garfield(Posted 2010) [#2]
same behavior under BMax with ConnectSocket instead of CreateTCPStream.
I used a local installed PureFTPd Manager FTP Server on my MacBook under OS-X to test it over LAN. But the same behavior as I attempt to connect the data connection with the second ConnectSocket with the calculated data port. The GUI hangs up and come back after 60-80 seconds with timeout from the server.


Brucey(Posted 2010) [#3]
Might be interesting to try the connection with something like libcurl in BlitzMax... (just to see the difference a proper library makes of the connections).