As the title says... Chat on...

User avatar
By FAlameda
#62851 I have written in Java a simplistic server that runs on the PC side of Wifi (IP 192.168.4.2 -> Port 53785)

The goal is for lua to request via WiFi new data every 40 ms to that server (25 blocks of data every second)

If I set an interval of, say, 300 ms, the Java server receives, more or less, a request every 300 ms (Although there are some requests that are delayed up to 900 ms)

When I reduce the interval below 200 ms, say 40 ms, the requests appear to be grouped and sent every 200 ms. It is as if a Nagle's algorithm, or something similar, is corrupting the transmission

I'm using NodeMCU 2.0.0 released a few days ago (Feb, 2017)

Is there an Nagle's algorithm active in the TCP stack of NodeMCU 2.0.0?
If that's the case, Is there any way to disable it?

How can NodeMCU send accurate sync signals via WiFi? UDP sockets?

Code: Select allwifi.setmode(wifi.SOFTAP)
wifi.sta.autoconnect(0)
wifi.ap.config({ssid = "ABCD", pwd = "123456789", channel = 6, auth = AUTH_WPA_PSK})

sck = net.createConnection(net.TCP, 0)

-- interval = 300
interval = 40   -- Interval between requests (ms)

timer = tmr.create()
timer:register(interval, tmr.ALARM_AUTO, function (t)
   sck:send('Nd0000')    -- Request new data block
   end)

sck:on("connection", function(socket)
   print('Socket Connected')
   timer:start()   
   end)
         
sck:on("disconnection", function(socket, error_code)
      print("Disconnected Error = "..error_code)
      end)
      
print("Connecting...")
sck:connect(53785,"192.168.4.2")