Added error logging to tcp