title: when to close a socket tcp
body: <p>I am working with a GPS tracker. I am listening gps tracker device through sockets. at the moment there are total 20 devices I am concurrently listening. I have few questions in mind</p>
  
  <p>Initially I was opening a socket and was closing after reading it and this loop goes on. I was receiving data from the device on time. The problem was that when the devices increases, the listening time from multiple devices gets slow and it was not realtime anymore then</p>
  
  <p>Then I chose not to close the socket after opening it. It became  realtime and gotten the response from each device on time but now when I checked the processes by running this command</p>
  
  <pre><code> sudo netstat -tulnap | grep :8153
  </code></pre>
  
  <p>There are total 750 connections established now. So I assume I might be doing something wrong? </p>
  
  <p>So I want to know is it how it should be done if I want to receive data from all the devices at a time? Or are there any better ways to implement it? If anyone can guide me to the right direction would be really appreciated. </p>
  
  <p>Note: my devices could go to 20 to 20,000 devices so the solution which you provide should be able to listen data from any number of devices real-time</p>
  
  <p>Thank you in advance </p>