[PHP] Socketing Question.

Joined
Mar 26, 2006
Messages
603
Reaction score
7
So I read a post earlier on in the forums about socketing. The more I read into it the more I wanted to learn. I've read most of the online books on it and they're truley isint much out there about php socketing, all of them are the basic same thing. Any suggestions on where I could read more into this?
 
The reason you cannot find much on PHP socketing is most likely that, in essence, it is a bad idea. PHP is simply not the right tool for that job, so even though you could, I would strongly advice against it. If you want to easily and quickly setup a socketserver, use JAVA or C# - those languages are much, much better suited for that task. If you don't mind the headache even C/C++ is a better choice than PHP.

If you want my more elaborate answer, see this post, it includes a zip with a fully working asynchronous socketserver written in PHP.
 
Last edited:
Years ago I looked into COMET as well, what I then found was the example here - though how up-to-date is will have to be seen.

Another good starting point for that might be the wikipedia page on it.

What you do, basicly, is create a very minimalistic webserver in PHP that can keep a connection open long after Apache (or whatever webserver you use) closes it. Essential in this is socket_accept which can keep listening on a specified port for incoming connections, and perform a specific action when a connection is inbound.

It really, really is a lot of hassle though :laugh:
 
Last edited:
Thank you as usual frag. I've been learning php for quiet some time now. And the more I've learned, the more it has intrigued me. I've read some of the wiki on comet last night but I decided to go to sleep. I'll keep reading into it though.
 
I've read both, also read your blog aswell. I don't exactly wanna learn it for making a server. I wanna learn more about it aswell as comet. If you could give me a link to where I could actually read up on both. That would be wonderfull
 
Back