Added error handling, changed tcp server's acceptor imp.