Jump to content

Multithreaded socket server


mmmuppet

Recommended Posts

I would like to make a muiltithreaded socket server.

 

I've made one which accepts one client and reads/writes data but I'm not sure how to achieve the 'multithreaded' effect.

 

Any pointers, no matter how small or seemingly obvious, will be gratefully received.

Link to comment
Share on other sites

PHP is single threaded.  I've seen hacks to try to make it multithreaded, but none of them were good.

 

 

Go with something like Java or C++ (I like the Boost Thread library, but I haven't used it much).  Or, I hear Python supports multiple threads (I might have dreamed that).

 

 

Edit:  http://php.net/pcntl_fork  I'm not sure quite how that works... I don't know if it's parallel execution or the CPU just alternates.  If it forks into a second process like the manual page says, you might be able to "multithread" with it.  (You would need to share variables though, and I'm not sure if variables are kept.)  I'm about to test it now.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.