Reputation: 2490
I want to know the client ip that connects to my lua server to find out if the connection comes from internet or intranet.
srv=net.createServer(net.TCP)
srv:listen(80,function(conn)
print(conn)
conn:on("receive",function(conn,payload)
ip = conn:getpeername()
print(ip)
conn:send("<h1> TEST.</h1>")
end)
conn:on("sent",function(conn) conn:close() end)
end)
I get the error:
PANIC: unprotected error in call to Lua API (stdin:2: attempt to call method 'getpeername' (a nil value))
Note: Im using this on the esp8266 chip and I have no experience with lua!
How can I find the IP of the client who connects?
Upvotes: 0
Views: 2347