Re: How to safely break read stream?
Re: How to safely break read stream?
- Subject: Re: How to safely break read stream?
- From: Greg Guerin <email@hidden>
- Date: Mon, 25 May 2009 21:48:10 -0700
Chris Gardner wrote:
When transferring data, I stop it using
CFReadStreamUnscheduleFromRunLoop()
and CFReadStreamClose().
When I am resuming to connect the same file in FTP servers, I
always get
the same problem which show error code 530 that meams user not
logged in.
When you say "resuming to connect the same file", do you mean you're
trying to reopen the same CFReadStream that was created earlier and
subsequently closed?
If that's what you're doing, then it won't work. Refer to the docs
for CFReadStream:
http://developer.apple.com/documentation/CoreFoundation/Reference/
CFReadStreamRef/index.html
Locate the description of CFReadStreamClose on that page, and note it
says, "Once closed, the stream cannot be reopened."
I guess the reason why I can not connect the same file again is
that I did not
interupt the read stream safely.
It doesn't seem to be a question of whether it was interrupted safely
or not. A CFReadStream can't be closed and reopened, according to
its docs.
If you want to start the download again, it appears you'll have to
use a new CFReadStream, and perform all the same setup you did before
starting the first download.
So my question is...How can I resume to connect and receive data
from the same file
in FTP servers or how can I interupt the read stream safely.
The evidence strongly suggests that CFReadStream doesn't support FTP
resume (called "restart" in RFC 959, the FTP reference doc.)
http://www.ietf.org/rfc/rfc959.txt
If you need to restart an FTP download, you'll probably have to
implement the FTP protocol yourself, using elements at a lower level
than CFReadStream. Or maybe you can use an existing FTP client
library that provides this feature.
The 'curl' command can do FTP, and it appears to be able to resume,
since it has exit codes that identify failures when trying to resume.
This is from 'man curl':
"curl is powered by libcurl for all transfer-related features.
See libcurl(3) for details."
so you might want to start there.
-- GG
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden