I am working on a client for an android device running on android version 4.4.2 and I have found some strange behavior from it. Most likely it is because it is waiting for more data before building a package, but I do not want that so i am trying to set the option TCP_NODELAY. However, there is no such function or variable anywhere to be found.
How do I set the SocketChannel to be in no delay mode? This is my current code for creating the socket channel.
sockChannel = SocketChannel.open(new InetSocketAddress(socket_ip_, socket_port_));
I have tried sockChannel.socket().setTCPNoDelay(true);
, but I have noticed no change. Am I on the right track? Am I missing something?
Thank you for your help.
If anyone finds this, I had the correct solution.
sockChannel.socket().setTCPNoDelay(true);
worked. The reason I didn't see any changes to the behaviour was because someone had changed the name of the app and had forgotten to document that he changed it. Thus I was starting the old program every time.
To access the socket options and functionality you can request the socket by writing .socket()
.