adko dobro
- Forum posts: 2
Mar 4, 2014, 12:00:33 PM via Website
Mar 4, 2014 12:00:33 PM via Website
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?
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?
Recommended editorial content
With your consent, external content is loaded here.
By clicking on the button above, you agree that external content may be displayed to you. Personal data may be transmitted to third-party providers in the process. You can find more information about this in our Privacy Policy.