UDP Server Example
Posted: Fri Nov 28, 2014 12:53 pm
Hi,
Does any one has a working UDP server example in LUA? I tried the following code, it seems that server starts but UDP messages are not received! note that I'm sending UDP messages to ESP8266 from my Android phone using UDP Sender App which works fine with other UDP servers.
Does any one has a working UDP server example in LUA? I tried the following code, it seems that server starts but UDP messages are not received! note that I'm sending UDP messages to ESP8266 from my Android phone using UDP Sender App which works fine with other UDP servers.
Code: Select all
pin=8
port=5000
print("IP:"..wifi.sta.getip()..", Port:"..port)
gpio.mode(pin, gpio.OUTPUT)
gpio.write(pin, gpio.LOW)
srv=net.createServer(net.UDP)
srv:listen(port,function(conn)
conn:on("receive", function(conn, pl)
print("Command Reveived")
if pl=="on" then gpio.write(pin, gpio.HIGH) else gpio.write(pin, gpio.LOW) end
end)
end)