title: Constantly monitoring a TCP streaming feed for data in Python
body: <p>I am writing a Python script in Python 3.5, I have a host and port and what I am trying to do is create the script so that it is constantly monitoring the provided host for data. The data is distributed through the TCP streaming feed in an xml format with a tag marking the start and end of the event.</p>
  
  <p>So what I am trying to do is basically monitor the TCP feed for new events which are marked between an xml start and end tag, then retrieve the event and handle it accordingly in my script. In addition, ideally I would need to have access to new data in the feed within milliseconds.</p>
  
  <p>The feed is a government feed that distributes alerts, the feed is streaming1.naad-adna.pelmorex.com and the port is 8080, what I want to do is monitor this feed for new alerts and then be able to access the alerts and handle them accordingly in Python. The feed sends a heartbeat every minute to indicate the connection is alive.</p>
  
  <p>I believe the best option would be to make use of Sockets though I am unsure of how to implement them in this specific use case. I do not have much experience with TCP feeds, and I was unable to find much online pertaining to how to handle a TCP feed in Python under my specific use case, I am able to handle the xml though once I am able to figure out how to pull it from the TCP feed.</p>
  
  <p>Any help would be appreciated.</p>