modify the socket array as a vector, and the loop uses INDEX replace of iterator