#23149 [Opn->Fbk]: fsockopen uses port as hostname
| From: | wez@php.net | Date: | Thu, 10 Apr 2003 14:01:50 +0000 |
| Subject: | #23149 [Opn->Fbk]: fsockopen uses port as hostname | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-37522@lists.php.net to get a copy of this message | ||
ID: 23149
Updated by: wez@php.net
Reported By: fcv at dev6 dot com
-Status: Open
+Status: Feedback
Bug Type: Sockets related
Operating System: Windows XP Pro
PHP Version: 4.3.1
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php4-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php4-win32-STABLE-latest.zip
On the line before the fsockopen call, add this line:
debug_zval_dump($this->host);
If it displays the correct host name, please try a snapshot. If it
does not display the correct host name, the bug is elsewhere in your
script.
Previous Comments:
------------------------------------------------------------------------
[2003-04-10 08:54:01] fcv at dev6 dot com
that syntax error on line 97 is not in my code. i didnt copy paste it.
the original line 97 is
$this->sock = fsockopen($this->host, $this->port);
//the syntax error was ($this->$host)
------------------------------------------------------------------------
[2003-04-10 08:50:41] fcv at dev6 dot com
Using fsockopen with the only 2 required parameters (hostname and port)
like this fails:
$myfilepointer = fsockopen($this->host, $this->port);
And returns the following error:
Warning: fsockopen() [function.fsockopen]: unable to connect to :23 in
c:\programas\apache group\apache\htdocs\es-operadores\engine\telnet.php
on line 97
The hostname is "10.1.2.9" (ip of my telnet server)
The port is 23.
$this is my telnet class initialized properly before use like this
$telnet = new telnet($hostname, $port);
function telnet($hostname, $port){
$this->host = $hostname;
$this->port = $port;
...
}
and line 97 is
$this->sock = fsockopen($this->$host, $this->port);
This setup worked perfectly with PHP 4.2.x and stopped working when i
upgraded to 4.3.1.
Now, the script attempts to connect to host "23" which is obviously
wrong. It assumes the second argument of fsockopen to be the host
instead of port.
If i insert a protocol argument before my host, it dumps data at an
amazingly brutal rate to Internet Explorer causing it to hog my system
memory and CPU (actualy, causes a memory leak in explorer. if i don't
ctrl-alt-del and kill explorer, it uses up to 1GB of ram).
Am i using the function properly? According to the online
documentation, yes! One weird thing is that you mention the protocol
argument is only mandatory if i use UDP and it is specified and a
prefix of the hostname (protocol://hopstname) and not as a separate
argument. But Dreamweaver MX autocomplete shows fsockopen(udp://,
hostname, port, err1, err2, timeout).
Thanks in advance!
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=23149&edit=1