moved socket parts to socket.h/.cpp