dongyuan9109
2012-05-25 23:50
浏览 296
已采纳

php中的fsockopen无法在服务器上运行

Here is my code:

$fp = fsockopen("74.63.172.37", 22, $errno, $errstr, 50);

if (!$fp) {

    echo "not connected";

} else {

    $out = "GET / HTTP/1.1
";
    $out .= "Host: 74.63.172.37
";
    $out .= "Connection: Close

";
    fwrite($fp, $out);
    $val = "";
    if (!feof($fp)) {
        echo "<br/>".fgets($fp, 128);
    }

    if (feof($fp)) {
        echo "<br/>Not connected";
    } else {
      echo "<br/>Connected";
    }

    fclose($fp);

    die();
}

On local server it gives me an output:

trying to connect
SSH-2.0-1.82_sshlib GlobalSCAPE
Connected

Whereas on server it gives me an output:

trying to connect
Not connected

I have another sftp server, where I could connect from both server and locally. What could be the issue?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

  • duangenshi9836 2012-06-01 06:50
    最佳回答

    Thanks ,, I found the solution. Destination Host has blocked my Server IP address.

    评论
    解决 无用
    打赏 举报
查看更多回答(2条)

相关推荐 更多相似问题