I started learning socket programming with php, i got a simple code from tutorial 1, which is the introductory example, here's the code :
<?php
$host = "127.0.0.1";
$port = 58;
set_time_limit(0);
$socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket");
$result = socket_bind($socket, null, $port) or die("Could not bind to socket");
$result = socket_listen($socket, 3) or die("Could not set up socket listener");
$spawn = socket_accept($socket) or die("Could not accept incoming connection");
$input = socket_read($spawn, 1024) or die("Could not read input");
$input = trim($input);
$output = strrev($input);
socket_write($spawn, $output, strlen ($output)) or die("Could not write output");
socket_close($spawn);
socket_close($socket);
?>
i am getting this error :
socket_bind() [function.socket-bind]: unable to bind address [0]: Only one usage of each socket address (protocol/network address/port) is normally permitted.
and another error when i change the IP host or the port... which is similiar to this...
so what's the problem ?