Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSOutputStream flushing

Tags:

flush

nsstream

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?

like image 857
Nils Avatar asked Jul 31 '26 05:07

Nils


1 Answers

Cocoa NSOutputStream send to a connection

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

like image 169
Blynkx Avatar answered Aug 01 '26 19:08

Blynkx



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!