Add TCP no delay option #130

Open
wants to merge 6 commits into
from

Conversation

Projects
None yet
4 participants

Adds the option to disable Nagle's algorithm. This is handy for sending a burst of very small TCP packets where latency matters. Since this is the first option, I'm not sure how we should handle configurations. Thoughts on this?

Matthias Plappert Add TCP no delay option. dcae835

This would be great to bring in, I also use this option in a version of CocoaHTTPServer to deal with an interaction between delayed ACKs and the server using separate writes for the headers and data. Couple comments:

  • It should be possible to set the option on a created socket. To support this the setter can call setsockopt() on the socketQueue if the socket already exists.
  • The flag could be stored with the other config bitflags similar to kIPv4Disabled.
  • I suggest renaming the methods to setTCPNoDelayEnabled and isTCPNoDelayEnabled. A getter call of [socket enableTCPNoDelay] could easily be read as enabling the option rather than querying for it.

Matthias Plappert added some commits Feb 20, 2013

Thanks for your feedback. I just updated the PR. Any additional thoughts? I assume it is safe to call setsockopt on a non NULL socket at any given time?

Matthias Plappert Update comment. 3a7d342

I think maintaining the setsockopt() call when the socket is created as you had before would be useful. Then you can set the option at any point - if the socket is not created yet the option will be set when it is, if the socket already exists then the option is set immediately.

In the getter it looks there is a kIPv6Disabled that should be kTCPNoDelayEnabled.

And yep, calling setsockopt() for any socket state will be fine, the function will return an error if it's unable to set the option.

Matthias Plappert added some commits Feb 27, 2013

Matthias Plappert Feedback. 5a6c04c
Matthias Plappert Whitespace. b6d6c0a

Finally got around to address your feedback. Do you have any further suggestions?

Nope, this looks good to me!

What needs to happen to get this merged in?

@robbiehanson needs to review and merge

Collaborator

chrisballinger commented Aug 25, 2015

@matthiasplappert @mattstevens Can you rebase this off the latest master and squash your commits? Thank you!

@max-potapov max-potapov pushed a commit to unisontech/CocoaAsyncSocket that referenced this pull request Dec 8, 2015

Maxim V. Potapov Add TCP no delay option #130 d955aae

@chrisballinger chrisballinger modified the milestone: 7.5, 7.5.2 Nov 9, 2016

(I am new to GitHub so I can only hope that I am going to put this comment where it actually belongs:)
Anyways, just wanted to say that I would also be very much interested in the "no_delay" feature. (I tried to include it myself based on the code by matthiasplappert but failed.) Now I am wondering, what are the chances that such a option will actually be included in v7.5.2? (If this is not going to happen, can you maybe recommend another library for iOS that supports "no_delay"?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment