tcp: added support for exceptions and registration of client tasks