Page 1 of 1
Only variables can be passed by reference
Posted: Fri Aug 31, 2007 7:25 pm
by shivam0101
I tried this tutorial,
http://devzone.zend.com/node/view/id/1086 - The making of a real server
in line 30, i am getting an error,
Only variables can be passed by reference
Posted: Fri Aug 31, 2007 7:42 pm
by volka
Interesting. And do you have a question?
p.s. What is line 30 of your script?
Posted: Fri Aug 31, 2007 7:56 pm
by shivam0101
Code: Select all
$ready = socket_select($read,null,null,null);
Posted: Fri Aug 31, 2007 8:01 pm
by volka
try
Code: Select all
$ready = socket_select($read,$write=null,$ex=null);
instead.
Posted: Fri Aug 31, 2007 8:36 pm
by shivam0101
thanks, that error vanished, i am getting a warning,
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:\wamp\www\zend.php on line 16
Could not bind to address
i modified the code to,
Code: Select all
$address = $_SERVER['REMOTE_ADDR'];
$port = 80;
$max_clients = 10;
at the top.
line 16 :
Code: Select all
socket_bind($sock, $address, $port) or die('Could not bind to address');
Posted: Fri Aug 31, 2007 8:51 pm
by volka
please try
Code: Select all
echo "socket_bind($sock, $address, $port) or die('Could not bind to address');\n";
socket_bind($sock, $address, $port) or die('Could not bind to address');
Posted: Sat Sep 01, 2007 12:55 am
by shivam0101
Code: Select all
$address=$_SERVER['REMOTE_ADDR'];
//$address = '192.168.0.100';
$port = 120;
$max_clients = 10;
Code: Select all
echo "socket_bind($sock, $address, $port) or die('Could not bind to address')\n";
socket_bind($sock, $address, $port) or die('Could not bind to address');
output:
socket_bind(Resource id #2, 192.168.0.1, 120) or die('Could not bind to address');
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.
Posted: Sat Sep 01, 2007 6:59 am
by volka
The error message pretty much says it all: Another socket is already bound to that port and you cannot bind more than one at a time to a certain port number.
Do you run this code in a loop or something?