reworking Socket implementation