title: what is the fastest way to generate random ip numbers in c?
body: <p>I need <em>fast</em> way to generate ip numbers that are valid (reserved ips are valid too).
  For now i am using this:</p>
  
  <pre><code>unsigned char *p_ip;
  unsigned long ul_dst;
  
  p_ip = (unsigned char*) &amp;ul_dst;
  for(int i=0;i&lt;sizeof(unsigned long);i++)
    *p_ip++ = rand()%255;
  ip.sin_addr.s_addr = ul_dst;
  </code></pre>
  
  <p>But sometimes it generate non-valid numbers, but this code can generate about 10k of valid ips in a second. Can anyone contribute?
  Thank you</p>