Adding two listeners : OnSocketClosedListener and OnSocketErrorListener.