transfercmd(cmd, rest_offset = nil)
private
Constructs a connection for transferring data
Show source
def transfercmd(cmd, rest_offset = nil)
if @passive
host, port = makepasv
conn = open_socket(host, port)
if @resume and rest_offset
resp = sendcmd("REST " + rest_offset.to_s)
if resp[0] != 33
raise FTPReplyError, resp
end
end
resp = sendcmd(cmd)
resp = getresp if resp[0] == 22
if resp[0] != 11
raise FTPReplyError, resp
end
else
sock = makeport
if @resume and rest_offset
resp = sendcmd("REST " + rest_offset.to_s)
if resp[0] != 33
raise FTPReplyError, resp
end
end
resp = sendcmd(cmd)
resp = getresp if resp[0] == 22
if resp[0] != 11
raise FTPReplyError, resp
end
conn = sock.accept
sock.close
end
return conn
end