Hi, can anyone help me please to enlighten my mind of the usage of stream_select ?
http://www.php.net//manual/en/function.stream-select.php
I really could not understand on how to use it.
Thank you in advance.
Hi, can anyone help me please to enlighten my mind of the usage of stream_select ?
http://www.php.net//manual/en/function.stream-select.php
I really could not understand on how to use it.
Thank you in advance.
Does your code already use streams or are you saying “how could I use this function?”
yes I already have this kind of code,maybe you are right how could i use this function
Here is my code…the problem is that i have another script that will connect to same server ip and port…but the second script is not working because there is other script that is already running.but if i will stop the first script and run the second script it receives data…that’s why i want to know how to use stream_select because i know it will accept multiple connection.
first.php
$server = stream_socket_server('tcp://'.$ipserver.':'.$port, $errno, $errorMessage);
if(!$server) {
echo "Error in socket";
}
else{
while($client = @stream_socket_accept($server,$timeout)) {
stream_copy_to_stream($client, $logfile);
fclose($logfile);
fclose($client);
}
}
this is my other script
second.php
$server = stream_socket_server('tcp://'.$ipserver.':'.$port, $errno, $errorMessage);
if(!$server) {
echo "Error in socket";
}
else{
while($client = @stream_socket_accept($server,$timeout)){
stream_socket_sendto($client,"sending message", STREAM_OOB);
$message = fread($client,1024);
echo "receive data".$message;
fclose($otherlogfile);
fclose($client);
}
}
Thank you in advance.