title: Error :Could not bind to socket in php programming
body: <p>these is an example showing TCP server that accepts a string as input, reverses it and returns it to the client.
  Here is Code:</p>
  
  <pre><code>&lt;?php
  $host = "127.0.0.1";
  $port = 1234;
  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");
  $result = socket_listen($socket, 3) or die("Could not set up socket listener\n");
  $spawn = socket_accept($socket) or die("Could not accept incoming connection\n");
  $input = socket_read($spawn, 1024) or die("Could not read input\n");
  $input = trim($input);
  $output = strrev($input) . "\n";
  socket_write($spawn, $output, strlen ($output)) or die("Could not write output\n");
  socket_close($spawn);
  socket_close($socket);
  ?&gt;
  </code></pre>
  
  <p>and got error like this:</p>
  
  <pre><code>  Warning: socket_bind() [function.socket-bind]: unable to bind address [0]: Only one usage of each socket address (protocol/network address/port) is normally permitted. in C:\xampp\htdocs\socket.php on line 5
  Could not bind to socket
  </code></pre>
  
  <p>What could I do to fix this ?</p>