Re: CFSocketSendData question
Re: CFSocketSendData question
- Subject: Re: CFSocketSendData question
- From: Douglas Davidson <email@hidden>
- Date: Wed, 4 Dec 2002 15:15:53 -0800
On Wednesday, December 4, 2002, at 02:42 PM, Mike Laster wrote:
CFSocketSendData timeout doesn't seem to work properly in 10.2.2. I
have a server bound to a socket, but frozen under gdb (to simulate a
hung server).
My client connects and attempts to send data to the server. If I use
a timeout of 0, the call blocks forever, as would be expected given
the situation.
However, if I use a timeout of 1, the send returns a second later, but
it returns kCFSocketSuccess, when I would have expected to get
kCFSocketTimeout.
As it is, I have no way of telling if the send succeeded or not.
Generally speaking, the success of a send operation indicates that the
data was sent, not that it was received. CFSocketSendData() returns
success if data was sent, i.e. if the kernel accepted the data. That
doesn't necessarily indicate anything about the state of the receiver.
In networking situations, in fact, it is not possible in general to
determine whether the other side received the data or not.
CFSocketSendData() is a convenience API, intended for simple write
operations. If you are sending large amounts of data, or have more
complex needs, I would recommend using an asynchronous write model,
along the lines of the CFSocket asynchronous read model. That is, add
kCFSocketWriteCallBack to your callback types, and use standard socket
APIs for writing when you determine that the socket is available for
writing. Alternatively, you can use CFStream, which handles most of
the complexity of this for you.
Douglas Davidson
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.