Re: ownership with sendto / CFSocketSendData
Re: ownership with sendto / CFSocketSendData
- Subject: Re: ownership with sendto / CFSocketSendData
- From: Jens Alfke <email@hidden>
- Date: Wed, 24 Feb 2010 08:11:51 -0800
On Feb 24, 2010, at 6:15 AM, Hado Hein wrote:
> If I send it with CFSocketSendData is the Data afterwards released. The
> docs don't say this.
In general, if the docs don't specify, it's because things follow the normal ref-counting conventions. I.e. the data is not released. Presumably the implementation either retains or copies it, so you are still in charge of any reference that you own.
> If it is not released it should be valid on my next send-cycle. So I'd
> reuse it, the pointed to data is read again (it mitght have changed in
> the meantime) and sended out. This is what I'd expect.
This wouldn't work if CFSocketSendData retains the CFDataRef and accesses it later (i.e. if it has to queue it because the socket's write buffer is full.) In that case you might be overwriting bytes that it hasn't sent yet, causing the wrong data to be sent. It would be safer to use a new CFData object every time.
—Jens _______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden