Open FerdinandoPH opened 1 year ago
Are you sure you closed only the data port and not the command port?
I'm pretty sure. Here is the code (Lua):
function sendData(data)
if data_skt == nil then
error("An error occurred during data sending.")
end
return Socket.send(data_skt, data)
end
function openDataSocket()
consoleWrite("Opening data channel on port " ..data_port.. "...\n")
data_skt = Socket.connect(ip, data_port, is_ssl)
end
function closeDataSocket()
Socket.close(data_skt)
data_skt = nil
end
(...)
function storeFile(filename)
sendResponsiveCommand("TYPE", "I")
enterPassiveMode()
sendCommand("STOR", filename)
openDataSocket()
recvResponse()
--consoleClear()
consoleWrite("Transfering " .. filename .. "...\n")
input = io.open(client_dir..filename,FREAD)
local filesize = io.size(input)
local i = 0
while i < filesize do
packet_size = math.min(524288,filesize-i)
i = i + sendData(io.read(input,i,packet_size))
end
consoleWrite("Transfer complete, now closing data socket on port " .. data_port .. "...\n")
closeDataSocket()
io.close(input)
recvResponse()
recvResponse()
enterPassiveMode()
listServerDirectory()
need_refresh = true
end
I've noticed that ftpd sends a 226 message when the transmission is over when I use FileZilla. Looking at the source code (specifically at ftpSession.cpp), I've noticed that that message is supposed to be sent when the buffer is 0. Maybe it has something to do with that?
Yes, once you close the data socket then server side will get a read of zero which marks the end of the data transfer, which the server will then send the 226 response. Can you show the logs of your transfer?
These are the logs of my client (1st) and ftpd (2nd)
I'm programming an FTP client for the 3ds. When I try to send a file to the server with STOR, and the file transfer is finished, I close the data port, but then I get an error
[ERROR] recv: Connection reset by peer
instead of the 226 command. I've tried delaying the closure of the data port, but with no luck. How am I supposed to tell ftpd that the STOR data transfer is overd? I'm using ftpd 3.1.0 (not classic) on a new 3ds (3dsx, rosalina 2.4.1)