Handles TCP server