PHP 4.0 Bug #7471: fsockopen() fails to open a connection using a hostname

From: Date: Thu, 26 Oct 2000 02:42:09 +0000
Subject: PHP 4.0 Bug #7471: fsockopen() fails to open a connection using a hostname
Groups: php.dev 
Request: Send a blank email to php-dev+get-36036@lists.php.net to get a copy of this message
From: tom@minnesota.com Operating system: NetBSD/Alpha 1.5_BETA PHP version: 4.0.3pl1 PHP Bug Type: Sockets related Bug description: fsockopen() fails to open a connection using a hostname Demonstration that fsockopen() DOESN'T works using FQDN. First I'll verify that my DNS works. This should eliminate the blame on DNS: # ping -c 5 www.php.net PING www.php.net (208.247.106.187): 48 data bytes 64 bytes from 208.247.106.187: icmp_seq=0 ttl=244 time=78.557 ms 64 bytes from 208.247.106.187: icmp_seq=1 ttl=244 time=69.776 ms 64 bytes from 208.247.106.187: icmp_seq=2 ttl=244 time=71.729 ms 64 bytes from 208.247.106.187: icmp_seq=3 ttl=244 time=67.823 ms 64 bytes from 208.247.106.187: icmp_seq=4 ttl=244 time=68.800 ms ----www.php.net PING Statistics---- 5 packets transmitted, 5 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 67.823/71.337/78.557/4.287 ms ---cut--- <?php $fp = fsockopen ("www.php.net", 80, &$errno, &$errstr, 30); if (!$fp) { echo "Unable to open a socket using fsockopen<br>\n"; echo "$errstr ($errno)<br>\n"; } else { fputs ($fp, "GET / HTTP/1.0\r\n\r\n"); while (!feof($fp)) { echo fgets ($fp,128); } fclose ($fp); } ?> ---cut--- Demonstration that fopen() works using FQDN. ---cut--- <?php $fp = fopen ("http://www.php.net/", "r"); if (!$fp) { echo "Unable to open a socket using fopen()<br>\n"; echo "$errstr ($errno)<br>\n"; } else { while (!feof($fp)) { echo fgets ($fp,128); } fclose ($fp); } ?> ---cut--- Demonstration that fsockopen() does works using IP address. ---cut--- <?php $fp = fsockopen ("208.247.106.187", 80, &$errno, &$errstr, 30); if (!$fp) { echo "Unable to open a socket using fsockopen<br>\n"; echo "$errstr ($errno)<br>\n"; } else { fputs ($fp, "GET / HTTP/1.0\r\n\r\n"); while (!feof($fp)) { echo fgets ($fp,128); } fclose ($fp); } ?> ---cut--- -- Edit Bug report at: http://bugs.php.net/?id=7471&edit=1

« previous php.dev (#36036) next »