Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

TCP_NODELAY - send bytes without delay

OP adkodobro

4th March 2014, 11:53 AM   |  #1  
OP Junior Member
Thanks Meter: 0
 
1 posts
Join Date:Joined: Feb 2009
I have next problem in developing app for android (Android studio, 4.0.3 kernel),

I communicate with my device over wifi. I need send from ever 20ms some bytes to my device. But I cannot send data more quickly like 100ms! When I use timer with 20ms period, system will send data in 100ms together. Setting timer to 200ms works, data sent ever 200ms. But In decreasing period to 20ms.

This is part of code:

// initialization of socket:

SocketAddress sockaddr = new InetSocketAddress(ip, parseInt(prt));
nsocket = new Socket();

//nsocket.setPerformancePreferences(0,1,2);
nsocket.setSendBufferSize(13);
nsocket.setTcpNoDelay(true);

// this is from timer, run every 20ms

nos = nsocket.getOutputStream();
nos.write(cmd);
nos.flush();


But android will send it with 100ms period! and together all bytes from every 30ms period of my timer

I think, it causes naggle algorithm. It's possible to switch it off. I found in documentation somethink about TCP_NODELAY, how can I use it? Is there any way how to send data to socket from android immediatelly?
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes