Consider the following PHP script:
<?php
function get_socket($host, $port) {
$fr = fsockopen($host, $port);
stream_set_blocking($fr, false);
return $fr;
}
// Assume $host1, $host2, etc are defined properly
$write_map[] = array('fr' => get_socket($host1, $port1),
'data' => str_pad("", 500000, "A"));
$write_map[] = array('fr' => get_socket($host2, $port2),
'data' => str_pad("", 500000, "B"));
$write_map[] = array('fr' => get_socket($host3, $port3),
'data' => str_pad("", 500000, "C"));
do {
$write_sockets = array();
foreach($write_map as $data) {
$write_sockets[] = $data['fr'];
}
$num_returned = stream_select($r = null, $write_sockets, $e = null, 30);
if($num_returned) {
foreach($write_sockets as $fr) {
foreach($write_map as $index => $data) {
if($data['fr'] === $fr) {
$len = fwrite($fr, $data['buf']);
if($len) {
$data['buf'] = substr($data['buf'], $len);
if(empty($data['buf'])) {
fclose($data['fr']);
/* ????????? */
}
}
}
}
}
}
} while(count($write_map));
?>
What should go in the ??????? above for this script to function properly?
Please answer through the comments I will make it publish on blog..............
[Thursday, February 21, 2008
|
3
comments
]
Popular Posts
- MySQL stored procedure&triggers
- php questions
- How we canmove into last changed position on info window close event On google map
- Pattern Matching in mysql
- MYSQL joins
- Jquery based dynamic adding and removal of html elements.
- securing a form with captcha
- Comparing a date with current date
- Css
- php Questions
3 comments
I had this one in the mok exam .. I can"t find the answer. please help !
answer is
unset($write_map[$index]);
answer is
unset($write_map[$index]);
Post a Comment
Please put your comments here. your questions, your suggestions, also what went wrong with me.