Transport and tsg fixes

* fix segfault in tsg
* fix problem in tls transport if client/server disconnects (wasn't detected anymore and could lead to endless loops)
* fix tsg transport when no data is available see #2130