Added code for sending messages over socket.