Re: NSURLConnection question
Re: NSURLConnection question
- Subject: Re: NSURLConnection question
- From: Roland King <email@hidden>
- Date: Sun, 12 Oct 2008 14:31:52 +0800
I don't think it actually does send it as fast as it can, I've been
using it for some of my stuff and I typically get one data callback
only with the whole document in it. I just checked the thing I'm
working on again and it got about 15K in one shot, that was
everything. I don't see any way to tune this.
It's not even clear that you'd get the data in much smaller packets if
you did use the lower-level socket handling code, the kernel probably
gives you what data it has at any point you ask for it, however
several packets may have come in during the time your user code was
processing, or someone else's code was running. My experience with
socket code over the years is that, with TCP at least, by the time you
get to ask for data, there's a lot more than one packet ready for you.
One different problem I've had with NSURLConnection is with the
connection:willSendRequest:redirectResponse where the documentation
claims you return nil and the connection will be cancelled but you
still get the data and then a connectionDidFinishLoading call. But I
never get that, I return nil, I get the data, but I don't get the
finish loading (nor an error) callback. I've given up trying that now
and I'm just cancelling the connection myself, annoying though. Anyone
used that call and gotten it to work?
On Oct 12, 2008, at 12:24 PM, Michael Ash wrote:
On Sat, Oct 11, 2008 at 7:07 PM, John Zorko <email@hidden> wrote:-
Hello, all ...
I want to alter how often NSURLConnection calls receivedData -- or
rather, I
want it to call it more often (even with fewer bytes) vs less often
(with
loads and loads of bytes). Can I do this with NSURLConnection or
some other
CF class, rather than have to go down to POSIX recv()? Basically,
I want to
be able to specify a max # of bytes to tell me about in one go.
I'd be surprised if it didn't already hand you bytes just as fast as
the system delivers them. Anything else would require internal
buffering and there's simply no reason to do anything of the sort. If
you're asking because you want to react to incoming data faster, I
doubt you can do better than you already have. If you have evidence to
the contrary, it would be interesting to hear. I'd expect to get calls
with a number of bytes roughly equal to the MTU of your connection
path, probably around 1.5kB. Is that not happening for you?
If your motivation is simply that your processing code needs to deal
with smaller units, just divide up the incoming data in your callback
before processing.
Mike
_______________________________________________
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
_______________________________________________
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