tel.lua 641 B

1234567891011121314151617
  1. -- a simple telnet server
  2. s=net.createServer(net.TCP,180)
  3. s:listen(2323,function(c)
  4. function s_output(str)
  5. if(c~=nil)
  6. then c:send(str)
  7. end
  8. end
  9. node.output(s_output, 0) -- re-direct output to function s_ouput.
  10. c:on("receive",function(c,l)
  11. node.input(l) -- works like pcall(loadstring(l)) but support multiple separate line
  12. end)
  13. c:on("disconnection",function(c)
  14. node.output(nil) -- un-regist the redirect output function, output goes to serial
  15. end)
  16. print("Welcome to NodeMcu world.")
  17. end)