improved the implementation of Socket module