problem with fsockopen()

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
munishsethi777
Forum Newbie
Posts: 3
Joined: Wed May 06, 2009 1:07 pm

problem with fsockopen()

Post by munishsethi777 »

Hi all, i m not a php guy but more of a .NET and java developer. Recently only i started on virtuaMart, Joomla and wanted to make use of USPS APIs for shipping rates etc.

I am facing a weird problem whose solution is not yet found in most of the forums or blogs.. its been 5 days i m banging my head here and there, but no luck yet.

here is the exception...
Warning: fsockopen() [function.fsockopen]: unable to connect to http://testing.shippingapis.com:0 (Unable to find the socket transport "http" - did you forget to enable it when you configured PHP?) in D:\Mynxx\administrator\components\com_virtuemart\classes\shipping\usps.php on line 229
Now basically i use PHP5 installed alongwith NuSphere IDE.. i belive problem is somewhere in my phpsettings and not the code..
Here i must mention that my php.ini have the following extensions enabled as.

allow_url_fopen = On
extension=php_openssl.dll
extension=php_soap.dll
extension=php_sockets.dll

i am using protocol as "http"


Kindly assist..
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: problem with fsockopen()

Post by John Cartwright »

HTTP is not a registered socket transport. You need to omit the http:// in the fsockopen() call, i.e.

Code: Select all

fsockopen('yourdomain.com', 80,  ..')
munishsethi777
Forum Newbie
Posts: 3
Joined: Wed May 06, 2009 1:07 pm

Re: problem with fsockopen()

Post by munishsethi777 »

thanks john.

i tried it without http but still same problem persists..

How can we register http socket transport in my windows xp?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: problem with fsockopen()

Post by John Cartwright »

HTTP is a stateless protocol. You do not stream with it (normally).

What is the exact error message you get when you omit the http://, and please post the relevant code.
munishsethi777
Forum Newbie
Posts: 3
Joined: Wed May 06, 2009 1:07 pm

Re: problem with fsockopen()

Post by munishsethi777 »

Hi..

Thanks for your suggestion.. i read that on many forums to remove the http, but u really woke me up..(credit still goes to u)..

Actually when i was removing http:// i still was getting an error and as usual i was not really reading , it was all about parsing and not fsocket etc..

so finally i got it going and now USPS response is coming through very nicely...
I still have some problem in response, but thats not PHP thing, its on USPS part.

thanks again..

see u very soon.
Post Reply