<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def closed(self, code, reason=None):
 """Called when the connection is closed"""

        self.emit('socket_closed', code, reason)
        self._recover_network_failure()