Re: iPhone: CFWriteStreamWrite
Re: iPhone: CFWriteStreamWrite
- Subject: Re: iPhone: CFWriteStreamWrite
- From: "SridharRao M" <email@hidden>
- Date: Mon, 7 Jul 2008 10:51:02 +0530
Hi
look at the CFWriteStream documentation
Returns the number of bytes successfully written, -1 if an error has
occurred, or 0 if the stream has been filled to capacity (for fixed-length
streams). If the stream is not full, this call will block until at least
one byte is written. To avoid blocking, either poll via CFWriteStreamCanAcceptBytes
or use the run loop and listen for the kCFStreamCanWrite event.
It will block if it tries to write at invalid ip & port .
You need to handle it by using Runloop.On Mon, Jul 7, 2008 at 7:29 AM, Mark Pauley <
email@hidden> wrote:
Yes, you've got to open the readstream and the writestream.
I'm not sure why your stream's status is open in this case... it should be in the opening state, not at open complete.
I'll try this out and see if I can't figure out what's with the confusing behavior.
Beyond that, if you're using the streams asynchronously you should get a canWrite callback.
_Mark
On Jul 5, 2008, at 1:18 PM, Jens Alfke wrote:
I have a problem transferring data using a CFWriteStream at least in
the ****** simulator, CFWriteStream does not accept data and blocks forever.
You can't talk about ***** development here without violating your NDA. At least not till next Friday...
The callback is called and then I create a read and write stream to the socket using
CFStreamCreatePairWithSocket.
After that I open a write stream calling CFWriteStreamOpen.
And the stream status shows open.
But CFWriteStreamCanAcceptBytes returns always false and CFWriteStreamWrite blocks forever.
Did you open the read stream too? (I'm not sure if that's required.)
Did you install callbacks on the CFStream too, to get notified when it's ready to write?
You may want to check out the TCPListener and TCPClient classes in my "MYNetwork" library:
They're based on the CocoaEcho sample code, but greatly extended. You can subclass these to implement your own protocols, instead of having to re-invent basic TCP support with CFNetwork.
—Jens
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
This email sent to email@hidden
_______________________________________________
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
_______________________________________________
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