#23149 [NEW]: fsockopen uses port as hostname

From: Date: Thu, 10 Apr 2003 13:50:41 +0000
Subject: #23149 [NEW]: fsockopen uses port as hostname
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-37519@lists.php.net to get a copy of this message
From: fcv at dev6 dot com Operating system: Windows XP Pro PHP version: 4.3.1 PHP Bug Type: Sockets related Bug description: fsockopen uses port as hostname 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 bug report at http://bugs.php.net/?id=23149&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=23149&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=23149&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=23149&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=23149&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=23149&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=23149&r=support Expected behavior: http://bugs.php.net/fix.php?id=23149&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=23149&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=23149&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=23149&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23149&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=23149&r=dst IIS Stability: http://bugs.php.net/fix.php?id=23149&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=23149&r=gnused

« previous php.bugs (#37519) next »