04 FTP Client
\ FTP 201907060520
fload TCP_IP.f
0 value sock
: Recieved
begin
temp$ 256 sock TCP.read ( dup cr . ) dup 256 >=
while
temp$ swap type
repeat
temp$ swap type cr
;
: SentRecieved ( adr count --- )
temp$ place
crlf$ count temp$ +place
temp$ count sock TCP.write drop
Recieved
;
: ConnectFTP ( IP_name TCP_port --- )
tcp_open
to sock
Recieved
;
: ftp_Login ( IP_name -- )
21 ConnectFTP
cr USER$ count SentRecieved
cr s" PASS$ count" SentRecieved
cr s" PWD" SentRecieved
;
: demo_FTP
CR cr
s" jiemang.com" temp$ place temp$ +NULL temp$ count drop
ftp_Login
s" HELP" SentRecieved
s" QUIT" SentRecieved
sock close drop
;
demo_FTP
\ NEW
: demo_FTP
CR cr
s" jiemang.com" temp$ place temp$ +NULL temp$ count drop
ftp_Login
s" HELP" SentRecieved.CommandPort
s" PASV" SentRecieved.CommandPort \ 227 Entering Passive Mode (66,147,244,90,163,43)
temp$ count DataPort.String$ place
DataPort.String> .DataPort.String
DataPort.IP$ count drop DataPort.Port ConnectFTP.DataPort
s" LIST" SentRecieved.CommandPort
Recieved.DataPort
\ 5000 ms
s" QUIT" SentRecieved.CommandPort
sock.CommandPort close
0 =
IF
CR ." CLOSE FTP command port OK ! "
else
CR ." CLOSE FTP command port error ! "
then
CR
sock.DataPort close
0 =
IF
CR ." CLOSE FTP data port OK ! "
else
CR ." CLOSE FTP data port error ! "
then
CR
;