#23149 [Opn]: fsockopen uses port as hostname

From: Date: Mon, 21 Apr 2003 15:41:58 +0000
Subject: #23149 [Opn]: fsockopen uses port as hostname
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-37989@lists.php.net to get a copy of this message
ID: 23149 User updated by: fcv at dev6 dot com Reported By: fcv at dev6 dot com Status: Open Bug Type: Sockets related Operating System: Windows XP Pro PHP Version: 4.3.1 New Comment: Additionally, the error code and errormsg are clear UNTIL i try my first read on the stream. I've seen comments on this situation somewhere on this site, and their solution (specify a timeout value) does not work at all. Behaviour is exactly the same on the latest snapshot (downloaded a few minutes earlier) Previous Comments: ------------------------------------------------------------------------ [2003-04-21 10:32:06] fcv at dev6 dot com Tried using debug_zval_dump($this->host); today (21) and it displays the correct hostname: "string(8) "10.1.2.9" refcount(2)" Downloading snapshot now. Will post results later on today. ------------------------------------------------------------------------ [2003-04-21 09:22:20] sniper@php.net No feedback was provided. The bug is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so and change the status of the bug back to "Open". Thank you. ------------------------------------------------------------------------ [2003-04-10 09:01:49] wez@php.net 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. ------------------------------------------------------------------------ [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

« previous php.bugs (#37989) next »