c++ server: implementation of socket select logic