Curl Problem: Could not connect to host

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Mou
Forum Newbie
Posts: 4
Joined: Fri Aug 24, 2007 6:21 am

Curl Problem: Could not connect to host

Post by Mou »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I have written the following code but found the error "Could not connect to host", I am unable to understand why this message is showing. I am giving my code snippet here:

Code: Select all

$ch = curl_init();
    curl_setopt ($ch, CURLOPT_URL, "https://24.113.250.119/localvocal/index.aspx");
    curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_setopt($ch, CURLOPT_POST, 1 );
	curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER,0);
	
    $result = curl_exec ($ch);
	if (empty($ret))
	{
    	// some kind of an error happened
    	die(curl_error($ch));
    	curl_close($ch); // close cURL handler
	}
	else 
	{
			$info = curl_getinfo($ch);
			curl_close($ch); // close cURL handler
		
			if (empty($info['http_code'])) {
					die("No HTTP code was returned"); 
			} else {
				// load the HTTP codes
				$http_codes = parse_ini_file("https://24.113.250.119/localvocal/index.aspx");
				
				echo "The server responded: <br />";
				echo $info['http_code'] . " " . $http_codes[$info['http_code']];
			}
		
	}
Also the URL is provided here is supposed to return an XML file which is not returning now since the curl could not connect to the host. Again if anyone of you has any alternative way of posting a stream of data without a form beside Curl, please provide me.

Thanx,
Mou


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
TheMoose
Forum Contributor
Posts: 351
Joined: Tue May 23, 2006 10:42 am

Post by TheMoose »

https://24.113.250.119/localvocal/index.aspx

Try opening that in your browser. The server is up (via pings), but is not accepting connections from 443 (SSL port), hence why your PHP code would say it is unable to connect.
Mou
Forum Newbie
Posts: 4
Joined: Fri Aug 24, 2007 6:21 am

Re:Curl Problem

Post by Mou »

Thanx Moose for your help. It helped me a lot to sort out my problem. Now my problem is solved.

Regards,
Mou
Post Reply