Skip to content

Instantly share code, notes, and snippets.

@TerryE
Created February 19, 2016 15:17
Show Gist options
  • Save TerryE/e423830cd61052d5ae37 to your computer and use it in GitHub Desktop.
Save TerryE/e423830cd61052d5ae37 to your computer and use it in GitHub Desktop.
Module net leakgages
-- Q & D function form of require tk enumerate the regristry fu7nctions
return function(delim,nocall)
print( '+++'..(delim or '==============='))
for i = 1,3 do collectgarbage() end
for i,f in ipairs(debug.getregistry()) do
print (i,f)
if type(f)=='function' and not nocall then
uart.write(0, ' Dummmy -')
local ok, msg = pcall(f, 'socket','Data-'..i)
if not ok then print(msg) end
end
end
print( '---'..(delim or '==============='))
end
enum_reg_funcs = require "enum_reg_funcs"
print ""
do
local nc, TCP, google = net.createConnection, net.TCP, '192.168.1.64'
-- local 'connection','receive' resp = 'connection', 'receive', 'OPTIONS * HTTP/1.1'
g2 = nc(TCP) g2:connect(80, google)
g2:on('connection', function(s2) print('conB', g2) g2:close() end)
g2:on('receive', function(s2,rec) print('rcvB',rec, g2) end)
g1 = nc(TCP) g1:connect(80, google)
g1:on('connection', function(s1) print('conA',s1) g1:close() end)
g1:on('receive', function(s1,rec) print('rvcA',rec, s1) end)
--[[ ]]
local l3 = nc(TCP) l3:connect(80, google)
l3:on('connection', function(s3) print('conC', s3) s3:close() end)
l3:on('receive', function(s3,rec) print('rcvC',rec, s3) end)
local l4 = nc(TCP) l4:connect(80, google)
l4:on('connection', function(s4) print('conD', l4) l4:close() end)
l4:on('receive', function(s4,rec) print('rcvD',rec, l4) end)
local l5 = nc(TCP) l5:connect(80, google)
l5:on('connection', function(s5) print('conE', l5) end)
l5:on('receive', function(s5,rec) print('rcvE',rec, l5) end)
enum_reg_funcs(" - - - - - - - - ", true )
end
tmr.alarm(0,30000,0, enum_reg_funcs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment