title: PHP Warning: socket_bind(): unable to bind address [98]: Address already in use
body: <p>Here is a simple server program:</p>
  
  <pre><code>&lt;?php
  for($i=0;$i&lt;=5;$i++)
  {
  $host = "xxxxx";
  $port=10000;
  set_time_limit(0);
  $socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n");
  $result = socket_bind($socket, $host, $port) or die("Could not bind to socket\n".socket_strerror(socket_last_error()) );
  $result = socket_listen($socket, 3) or die("Could not set up socket listener\n".socket_last_error() );
  $spawn = socket_accept($socket) or die("Could not accept incoming connection\n");
  $input = socket_read($spawn, 2048) or die("Could not read incoming connection\n");
  $input = trim($input);
  echo "Client Message : ".$input."\n";
  socket_close($spawn);
  socket_close($socket);
  flush(); @ob_flush();
  sleep(10);
  }
  ?&gt;
  </code></pre>
  
  <p>I am need to bind that port no. again after closing socket.
  Every time, In the first loop there is no error, In the second loop iam getting error. I thought, the port wasn't cleared. I am using Cent OS, I tried some linux commands to refresh the ports,but no use.<br> Can Anybody explain what actually happening in this case?
  How can re use the same ports after closing in the same process?</p>