wifi.setmode(wifi.STATIONAP)
cfg={}
cfg.ssid="myname"
cfg.pwd="mypass"
wifi.ap.config(cfg)
sv=net.createServer(net.TCP)
sv:listen(80,function(c)
c:on(\"receive\", function(c, pl) print(pl) end)
c:send(\"HTTP/1.1 200 OK\\r\\n\")
c:send(\"Content-Type: application/json\\n\\n\")
c:send(\"ok\") end)
So it works great and i return ok , for every input communication,
Question is, what happens, if i want to send data to the client, or even return different data on next receive ?
For example the esp8266 got a request to check something in my mcu , then i want to respond to him with a specific value,with the check results, how would i do that ?
Do i have to recreate again the function with a different respond like this(seems very wrong) :
sv=net.createServer(net.TCP)
sv:listen(80,function(c)
c:on(\"receive\", function(c, pl) print(pl) end)
c:send(\"HTTP/1.1 200 OK\\r\\n\")
c:send(\"Content-Type: application/json\\n\\n\")
c:send(" ****different respond !!! ") end) // ** new respond changed every time
or there is a different way to just set a different respond/ send back data to the client ?
thanks .