473,385 Members | 1,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

handle muliple clients in php socket server-udp

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
Jan 12 '08 #1
0 4113

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: User | last post by:
Hi, I tried to find the information over the internet but didn't find any answers. I'm looking for a server side code example of winsock accepting many clients. I know that in VB.NET it is...
2
by: mlc | last post by:
I have a server (in win32 C++, TCP) that listens and accepts socket calls, then via CreateProcess and handle inheritence over the command line starts up a process to handle the client request. Is...
2
by: Ian | last post by:
Hi, Is anybody aware of problems in .NET where the handle count of an application increases over time? We have a server application that is hosted in a Windows Service and accepts socket...
1
by: Riddle | last post by:
Hi, I'm relatively new to socket programming and I'm having trouble understanding them! I've (using help from tinternet and a useful tutorial) made a client and server that are able to talk to one...
2
by: =?Utf-8?B?YmJn?= | last post by:
Hi all, I am testing how well my server application is connecting to multiple clients and give and take some information. All actions(connect, accept, send, receive) are performed by async...
1
by: almir | last post by:
hi, i need to notify clients about change that happened on server. there will be about 2000 clients each will have my service running in it, what would be the best way to notify only few of them...
4
by: setiarakesh | last post by:
I have designed a socket Server and developed asynchronous server . It is working fine with 60 Clients which are connecting to ths Server running at Machine (2 GB RAM and OS is Windows 2003...
1
by: kurrachaitanya | last post by:
Lecture Saying that: I am generally expecting most of you to work n java.If you prefer to use c/c++ version of the programs,you may,but the assistance in the lab sessions will be very much geared...
1
by: kurrachaitanya | last post by:
YOUR TASK IS AS FOLLOWS : The server is written in such a way that only one client can connect to it at any time.modify the server sothat several clients can be connected to it(and later disconnect...
1
by: Okko Willeboordse | last post by:
Hello, SocketServer.ThreadingTCPServer accepts connections (clients can connect) before and after it's server_forever method is called, see below for an example. IMHO it should only accept...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.