add tcp server function for endpoint.