|
 |
|
มีปัญหาเรื่อง curl multi จึงขอให้ผู้เชี่ยวชาญ ช่วยด้วยครับ |
|
 |
|
|
 |
 |
|
<?php
$mh = curl_multi_init();
// loop ประ 20000
while($phbdROW = mysql_fetch_assoc($phbdRS)) {
curl_setopt($conn[$i],CURLOPT_RETURNTRANSFER,1);
curl_setopt($conn[$i],CURLOPT_POST, 1);
curl_setopt($conn[$i],CURLOPT_POSTFIELDS, $Parameter);
curl_multi_add_handle ($mh,$conn[$i]);
}
//เขียนแบบนี้ มีปํญหา loop เยอะมากๆ
do {
$mcRes=curl_multi_exec($mh,$threads);
} while ($threads > 0);
//จากด้านบนที่มีปัญหา loop เยอะ เลยเปลี่ยนมาเป็น แบบนี้แต่เกิดปัญหา connect fail ค่อนข้างเยอะ
do {
$mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
while ($active && $mrc == CURLM_OK) {
if (curl_multi_select($mh) != -1) {
do {
$mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
}
}
//loop get connent : มีปัญหา ค่า respone ไม่มี
$i=0;
foreach($phonearray as $phone_no){
$result=curl_multi_getcontent($conn[$i]);
$parser = new xml();
$parser->parse($result);
$mtdata=$parser->get_data();
$STATUS=$mtdata["status"];
$DETAIL=$mtdata["detail"];
$TRANSID=$mtdata["transid"];
curl_multi_remove_handle($mh,$conn[$i]);
curl_close($conn[$i]);
$i++;
}
ช่วยหน่อยนะครับ ขอบคุณครับ
?>
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2010-07-01 10:43:15 |
By :
JAK |
View :
1029 |
Reply :
0 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
|
|

|
Load balance : Server 02
|