-->
Page 1 of 2

net.getServer() or node.closeServer()

PostPosted: Fri May 22, 2015 11:20 pm
by Larry
If a server is created with
Code: Select allserver = net.createServer(net.TCP, 30)
server:listen(80)

then the reference to the server is lost, for instance, because a file is reloaded, then there is no way to close that server or get access to it. If the server is not closed then it is not possible to create a new server without resetting the board.

Is it possible to add either net.getServer() that returns the server created by net.createServer(), or net.closeServer() that releases that server.

Re: net.getServer() or node.closeServer()

PostPosted: Tue May 26, 2015 12:45 am
by TerryE
Why not just make server a global? Then you can do something like:
Code: Select allif server then server:close () end

Re: net.getServer() or node.closeServer()

PostPosted: Fri Jun 26, 2015 9:27 pm
by Larry
If some other code calls server net.createServer(net.TCP, 30) and does not make it public then the only solution at present is to reboot. This is already a static object buried somewhere in the code. Exposing that object makes the API more complete.

Re: net.getServer() or node.closeServer()

PostPosted: Sat Jun 27, 2015 8:48 am
by TerryE
Agreed, but most ESP8266 Lua apps are single developer, and the fact that the SDK only supports one TCP server at a time is a design constraint. Surely this isn't a big issue in the overall scheme of things.