Hi, 

I am trying to access a remote file by opening a socket on port 80 but keep
getting refused... 

The server does listen on port 80 as i can access it via browser... 

my code reads like this: 
<?php 
$Destination =
"http://srv157:7001/Palmeira2Application/palmeira2.servlets.communicator.Com
municator";
$Request = "action=$action&username=$uname&password=$password"; 
$cfgTimeOut = 20; 

$theURL = parse_url($Destination); 
$host = $theURL["host"]; 
$path = $theURL["path"]; 
$port = $theURL["port"]; if ($port=="") $port=80; 
$header = "POST ".$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"; 
$header .= "Content-Type: text/xml\r\n"; 
$header .= "Content-Length: ".strlen($Request)."\r\n"; 
$header .= "Content: \r\n\r\n"; 
$msg = $header. $Request ; 
$Response = ""; 

echo $port; 
//echo $host; 

// 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 (".$Destination.").<br>"; 

echo "<a href=\"javascript:history.go(-1)\">Try another</a>";} 

print "$response\n"; 

print "hello"; 
?> 

any suggestions pl?? 

TIa, 
sands 
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to