Fix bug with multiple event listeners for the tcp server