Edmhs
Edmhs

Reputation: 3731

Writing Socket Servers in PHP is it good idea?

Is it good idea to write Socket Servers using php??

here is how to article: http://devzone.zend.com/article/1086

question:

What is different from writing socket servers in other languages like c, c++, python, ..?

how about security?

speed?

"Socket Servers normally run continuously as a service or a daemon."

php running continuesly?? will it work for a days, weeks, months?

what would be better way?

i need service that php application can connect to and send, receive data.

Upvotes: 0

Views: 836

Answers (1)

MarkR
MarkR

Reputation: 63538

It is not generally a good idea to write a (nontrivial) PHP program which executes for a long time. This is because its memory management is deficient in various ways, in particular, it fails to ever deallocate circularly referenced structures. Some other objects also leak. For example http://uk.php.net/manual/en/function.create-function.php allocates a function which can never be freed; call this inside a loop and you are eventually dead. In other languages it is possible to create function objects which are garbage collected.

However, if you are careful and test it properly, simple servers CAN be written in PHP, you just have to avoid doing any of the things which cause it to leak memory; most of them are easy to avoid in a small simple program.

Upvotes: 3

Related Questions