我怎么知道我的卷曲代理是否已关闭?

In PHP i am using a proxy with curl with the following :

CURLOPT_HTTPPROXYTUNNEL, 1,
CURLOPT_PROXY, ''.$current_proxy.'',

and i have a DB with backup proxy ip's in it, but i want to know how i can detect if the proxy has gone down so it can switch the variable $current_proxy.

What do you suggest for detecting if a server is down? Thanks.

Curl doesn't distinguish whether proxy is down or page doesn't exist (or server where this page located is down). That's why you need invent workaround by yourself. At least Daniel from Haxx AB said it.

list.txt contains such as:

1.2.3.4:2487 123.123.123.123:3248

etc. php code like this ...

$url = "http://www.google.com";
$proxies = file("list.txt");

foreach($proxies as $proxy)
{
    $ch = curl_init($url);
    curl_setopt($ch,CURLOPT_PROXY,$proxy);
    curl_setopt($ch,CURLOPT_HTTPPROXYTUNNEL,$proxy);
    $page = curl_exec($ch);
    curl_close($ch);
    $check = stripos($page,'</html>'); // not pretty :)

        if($check > 0)
        {
            echo $proxy . " Works!";
        }else{
            echo $proxy . " Is Dead!";
        }
}

You can just try to connect to the proxy with fsockopen like that:

$proxy = '98.255.255.255:8080';
$timeout = 5;
$splited = explode(':',$proxy); // Separate IP and port
if($con = @fsockopen($splited[0], $splited[1], $errorNumber, $errorMessage, $timeout)) 
{
    echo 'Connection successful, PROXY works!';
} else {
    echo $errorNumber . ' ' . $errorMessage;
}