Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How do you compare CURL and Socket programming in PHP? What are the pros and cons of both? And why do you prefer one over the other?

<p>I was just wondering that we may be able to achieve the same thing using both of these methods i.e. CURL or Socket. Has anybody tried to compare these two on performance, and any other parameters? </p>

user-image
Question added by Atif Majid , Senior PHP Programer/Team Lead , RedApple Apartments AB
Date Posted: 2014/11/01
Majid Hameed
by Majid Hameed , Senior Java Developer , Check24 Vergleichsportal GmbH

* Socket performs better as compared to Curl.

* Usage wise Curl is better as compared to Socket.

* If you want to connect to machines over internet on different non standard ports using Sockets you might have to deal with security issues; firewall etc.

* Hosting support might be another factor but its very minimal.

Performance Statistics - Source: http://goo.gl/3q9oZ9

Muhammad Majid Saleem
by Muhammad Majid Saleem , Senior PHP Developer / Project Manager , SwaamTech

I believe, both have their own advantages and disadvantages over each other. But I would suggest to user cURL.

 

I would recommend, you are better off using cURL because:

- It knows HTTP better than fsockopen().

- It opens its own sockets.

- It is well friend of HTTP probably.

- It has standard client to perform its actions.

 

Here is good compression between PHP cURL and PHP Socket: http://sysmagazine.com/posts/166633/

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.