My objective is to open x ports and if a error is caught it should divide the number of ports by 2, and try again until I stick with a max number of ports that can be opened.
At the moment, when i run it does everything ok but only gives the errors at the end, and because of that it never divide the original number by 2, also it gives this warning:
warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
I tried to setMaxListeners() but it didn't fix it