PHP connect to external ip with port

柔情痞子 提交于 2019-12-25 08:49:54

问题


I have a dedicated server running a MSSQL and an apache server, only listening to port 8080 (the apache), and i have some XML in there that i want to access from another domain(hosted server).

I tried fsockopen like this:

<?php
$fp = fsockopen("199.175.125.222", 8080, $errno, $errstr, 30);
if (!$fp) {
    echo "$errstr ($errno)<br />\n";
} else {
    $out = "GET / HTTP/1.1\r\n";
    $out .= "Host: www.example.com\r\n";
    $out .= "Connection: Close\r\n\r\n";
    fwrite($fp, $out);
    while (!feof($fp)) {
    echo fgets($fp, 128);
}
fclose($fp);
}
?>

but got nothing, only a:

Warning: fsockopen() [function.fsockopen]: unable to connect to 199.175.125.222:8080 (Connection timed out) in /home/reb/public_html/testing/index.php on line 2 Connection timed out (110)

php_sockets is enabled and all... Any ideas? now im trying WAMP on this dedicated server, to see if any config may help

Thank you

来源:https://stackoverflow.com/questions/8004140/php-connect-to-external-ip-with-port

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!