lua_examples/lfs/HTTP_OTA: move :connect() after :on()

IMHO, it's generally good style to register the callbacks first.
This commit is contained in:
Nathaniel Wesley Filardo 2020-04-05 23:57:30 +01:00 committed by Marcel Stör
parent e1a81aa114
commit 31c71c0e5d
1 changed files with 2 additions and 2 deletions

View File

@ -12,8 +12,7 @@ local n, total, size = 0, 0
doRequest = function(socket, hostIP) -- luacheck: no unused
if hostIP then
local con = net.createConnection(net.TCP,0)
con:connect(80,hostIP)
local con = tls.createConnection(net.TCP,0)
-- Note that the current dev version can only accept uncompressed LFS images
con:on("connection",function(sck)
local request = table.concat( {
@ -28,6 +27,7 @@ doRequest = function(socket, hostIP) -- luacheck: no unused
sck:send(request)
sck:on("receive",firstRec)
end)
con:connect(80,hostIP)
end
end