Core: fixed wrong indices in listening sockets compare loops. Proper use is "ls[i]" and "nls[n]". Previous code used it wrong in several places, likely due to cut-n-paste errors.