title: Determing established connection time
body: <p>I'm trying to find a way to determine how long a connection as been established to any IP and any port and I want to use C.</p>
  
  <p>So far, I can get the remote IP and port as well as the local IP and port and the program name and its PID by forking and calling netstat and extracting data from it byte-by-byte.</p>
  
  <p>However, I prefer if theres a standard API thats included with linux that I can directly use in my program so I don't always have to call external programs to see if a connection is established and for how long.</p>
  
  <p>Is there a way I can do this without the need for calling external programs and extracting output from them?</p>
  
  <p>What I want to do later in my program is kill a process if the established connection time is way too long (I'm trying to defeat the slowloris DOS attack).</p>