Re: php,sockets-help!

From: Date: Wed, 09 Jan 2002 16:27:33 +0000
Subject: Re: php,sockets-help!
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-79927@lists.php.net to get a copy of this message
Probably here : $header .= "User-Agent: PHP/4.0.6 (Apache/1.3.20)\r\n\r\n"; you have two new lines instead of one. HTH Regards, Andrey Hristov ----- Original Message ----- From: "Sandeep Murphy" <Sandeep.Murphy@oni.pt> To: <php-general@lists.php.net> Sent: Wednesday, January 09, 2002 6:23 PM Subject: [PHP] php,sockets-help! > > Hi, > > I am opening a socket on a remote server(weblogic) and sending my username > and psswd to authentify them... > > I figure my php is opening the socket as no errors r being trapped.. However > the response is a blank page instead of an xml formatted response...why??? > how can i rectify this?? > > Please helpp!!! > > TIA, > sands > my code is as below: > > > <?php > > $uname = "username"; > $password = "password"; > > ?> > > > > <?php > > $Destination = > "http://srv157:7001/communicatorServlet"; > $Request = "username=$uname&password=$password"; > $cfgTimeOut = 20; > > $theURL = parse_url($Destination); > $host = $theURL["host"]; > $path = $theURL["path"]; > $port = $theURL["port"]; if ($port=="") $port=80; > $header = "GET ".$path." HTTP/1.0\r\n"; > $header .= "Host: ".$host."\r\n"; > $header .= "Accept: */*\r\n"; > $header .= "Accept-Language: en\r\n"; > $header .= "User-Agent: PHP/4.0.6 (Apache/1.3.20)\r\n\r\n"; > $header .= "Content-Type: text/xml\r\n"; > $header .= "Content-Length: ".strlen($Request)."\r\n"; > $header .= "Content: \r\n\r\n"; > $msg = $header . $Request; > $Response = ""; > > > > // open a socket > if(!$cfgTimeOut) > // without timeout > $fp = fsockopen($host,$port); > else > // with timeout > $fp = fsockopen($host,$port, &$errno, &$errstr, $cfgTimeOut); > > > if ($fp) { > if (!fputs($fp,$msg,strlen($msg))) { return false; } // S > E N D > > while (!feof($fp)) {$Response .= fgets($fp,32768);} > > fclose($fp); // R E C E I V E > > } else > { > echo "Unable to access servlet (".$Destination.").<br>"; > > echo "<a > href=\"javascript:history.go(-1)\">Try another</a>";} > > print "$response\n"; > > print "hello"; > ?> > > -- > PHP Windows Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net > For additional commands, e-mail: php-windows-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#79927) next »