i am trying to broadcast continuous data from server using udp connection...
while accessing from single client its working fine...
but while accessing from multiple clients its not working and throwing an error like
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\client1.php on line 16
Warning: socket_recvfrom() [function.socket-recvfrom]: unable to recvfrom [0]: The operation completed successfully. in C:\xampp\htdocs\socket\client1.php on line 17
my server.php as follows...
<?php
$address='192.168.1.18';
$port=9000;
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
$opt_ret = socket_set_option($sock, SOL_SOCKET, SO_BROADCAST, TRUE);
for($i=1;$i<=90;$i++){
echo $i;
$send_ret = socket_sendto($sock, $i, strlen($i), 0, $address, $port);
if($i==90){
$i=0;
}
sleep(1);
continue;
}
socket_close($sock);
?>
my client.php as follows...
<?php
echo $_SERVER['HTTP_X_FORWARDED_FOR']."<br>";
$address = '192.168.1.18';
$port = 9000;
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_bind($socket, $address, $port);
socket_recvfrom($socket, $buf, 12, 0, $address, $port);
echo $buf;
?>
Please any one help me........
Thanks in Advance