#23149 [Opn]: fsockopen uses port as hostname

From: Date: Thu, 10 Apr 2003 13:54:02 +0000
Subject: #23149 [Opn]: fsockopen uses port as hostname
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-37521@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: 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) Previous Comments: ------------------------------------------------------------------------ [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 (#37521) next »