ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

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
تم إضافة السؤال من قبل Atif Majid , Senior PHP Programer/Team Lead , RedApple Apartments AB
تاريخ النشر: 2014/11/01
Majid Hameed
من قبل 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
من قبل 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/

المزيد من الأسئلة المماثلة