Allows to set a handler that will be called when a connection is about being closed.
This method could be used to establish some especial actions to be taken before the connection is completely unrefered. This function could be used to detect connection broken.
This handler is used by:
NOTE: You must not free the connection received at the handler. This is actually done by the library.