Nils
Nils

Reputation: 31

NSOutputStream flushing

I'm working on an iPhone App and wanted to use:

CFStreamCreatePairWithSocketToHost(NULL, url, port, &serverReadStream, &serverWriteStream);

And after that use the:

[serverWriteStream write:[sendData bytes] maxLength:[sendData length]];

I want to send small Packages of 5 Bytes to get realtime updates.

My problem is now, that the stream only sends data when the buffer is full. So I need some kind of a flush method or tell the stream to immediately send the data.

Searching for this problem ended in finding 'TCP_NODELAY' which seems to belong to the undocumented API ( which I mustn't use for AppStore, correct me if im wrong pls ) and even if I might be allowed to use it, I would have to change the creation of the streams, right?

Upvotes: 3

Views: 4753

Answers (1)

Blynkx
Blynkx

Reputation: 59

Cocoa NSOutputStream send to a connection

Just add an "end of line" ( "\n" ) to your string. work for me.

Upvotes: 5

Related Questions