Paypal ipn找到了停止使用PHP的代码

I got to check out deeper into my paypal ipn code. I used INSERTS to make sure I know where the code stops working. The code will not pass this section. Here is the code:

    $res = fgets ($fp, 1024);

Thus, it never reaches

            if (strcmp($res, "VERIFIED") == 0) {

Here is most of the code:

// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
    $value = urlencode(stripslashes($value));
    $value = preg_replace('/(.*[^%^0^D])(%0A)(.*)/i','${1}%0D%0A${3}',$value);// IPN fix
    $req .= "&$key=$value";
}

// post back to PayPal system to validate
$header = "POST /cgi-bin/webscr HTTP/1.0
";
$header .= "Content-Type: application/x-www-form-urlencoded
";
$header .= "Content-Length: " . strlen($req) . "

";

$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30); 

if (!$fp) {
    // HTTP ERROR
} else {    

    fputs ($fp, $header . $req);
    while (!feof($fp)) {
        $res = fgets ($fp, 1024);
        if (strcmp($res, "VERIFIED") == 0) {

Does anybody know why it does not pass this section of the paypal ipn code?