Re: Problem closing CFWriteStream [moved from darwin-dev, as it seems more appropriate here]
Re: Problem closing CFWriteStream [moved from darwin-dev, as it seems more appropriate here]
- Subject: Re: Problem closing CFWriteStream [moved from darwin-dev, as it seems more appropriate here]
- From: Jens Alfke <email@hidden>
- Date: Fri, 20 Jun 2008 09:08:38 -0700
On 20 Jun '08, at 2:23 AM, Eli Bach wrote:
Basically, I'm trying to something that I think would be fairly
common, which is doing an orderly disconnect, where a client sends a
'logout' message and closes the write stream, the server receives
the 'logout' [and then the read stream says it's not connected
anymore], then the server replies with a 'logged out' message and
closes it's write stream, which the client receives and then the
client's read stream says it's not connected anymore.
Funny coincidence; I was just doing the same thing yesterday*. I also
haven't seen a way to do a half-close with CFStreams, so I changed my
protocol so that the two sides coordinate when to close:
1. The peer that wants to close sends a "bye" message;
2. The other peer responds to that by sending a "bye" message back;
3. The first peer closes the socket when it receives the response.
Third, if an error happens, and I want to tear down the connection
in a 'disorderly' fashion [ie, not waiting for the send buffer to be
flushed to the client, which could potentially take minutes for TCP
to timeout], how do I do this?
Good point; I hadn't thought about that case. But if you're using the
API in async mode (with a runloop) then hopefully the close shouldn't
block anyway, even if behind the scenes it takes a while for the
timeout. But I haven't tested this.
—Jens
* In my BLIP library <http://projects.mooseyard.com/wiki/1/BLIP>
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden