Added code for setting up socket.