Download

Enable/Disable Nagle Algorithm Feature (FSocket)

Hello,

I modified the engine source to give a developer the option of turning off the Nagle algorithm (sockets: TCP_NODELAY).

Considering that UE4 is a game engine, I am surprised that you don’t already offer this option. You must be turning it off in your own client/server system.

This feature would benefit a number of developers. Please consider adding it to the API.

The only snag I ran into was the fact that TCP_NODELAY wasn’t defined in the Android build. This is strange because it is defined in the Android SDK. I kludged it with my own define, but if you officially add this feature then I suspect you need to include “tcp.h” somewhere, or stop doing whatever is blocking that definition.

Here’s the code I added to your source (obviously you also have to add the virtual function to the FSocket class and implement it in all derived classes).
This code has been tested with Windows x64 and Android “Multi”.



/* For some reason this isn't defined in the Android build */
#if !defined(TCP_NODELAY)
#define TCP_NODELAY 1  
#endif

/* Enables/Disables the Nagle algorithm */
bool FSocketBSD::SetNagle(bool bEnable)
{
  int Param = bEnable ? 0 : 1;
  return setsockopt(Socket, IPPROTO_TCP, TCP_NODELAY, (char*) &Param, sizeof(Param)) == 0;
}


That same code is in the FSocketBSDIPv6 definition as well.

Thanks so much for opening up to us. I’ve dreamed of this for a long time and I hope that what I’m working on will help make Epic a part of the Next Gen (hint: it’s not about graphics power this time).

-Jin

If you could submit this as a pull request on GitHub, there might be a good chance for it to get merged.

Ooh, that’s a little intimidating. :slight_smile:
But I’m on it!