Sockets: refractoring and comments