implemented code with sockets