Jump to content

[Answered] Php, Sockets, And Persistent Service Design


reinderien

Recommended Posts

Hello.

 

First, thanks for this service - it's a great testbed for web app design, and the functionality is quite good especially considering the price.

 

I'm trying to learn how to design a socket server in PHP. This server would run in the background, and perform low-bandwidth operations over TCP. http://www.heliohost...s/languages/php indicates that this installation of PHP supports sockets, which is good.

 

I face several challenges. Firstly, I think this would require the use of a cron job that checks for a certain process string (the PHP interpreter + script), and if it does not exist, starts it and backgrounds it with an "&". However, even my most rudimentary cron job experiments that don't even use PHP seem to not work - scheduling a daily cron job in cPanel to concatenate a simple string to a file in my home directory does not seem to produce that file. So I don't know what's going on there.

 

Also, reading from an account of a partially related situation (http://www.helionet...._mode__threaded), it seems that by default it is impossible to have a TCP port open for general use.

 

Do you have any advice to address these issues?

 

Thank you.

Link to comment
Share on other sites

Sorry, but HelioHost does not support socket servers due to security reasons. Also, I do not know of any other host (even paid) that supports this without purchasing a Virtual Private Server.

 

However, you could have your web page call a script via ajax every five seconds to check for updates to some information.

Link to comment
Share on other sites

Sorry, but HelioHost does not support socket servers due to security reasons. Also, I do not know of any other host (even paid) that supports this without purchasing a Virtual Private Server.

 

However, you could have your web page call a script via ajax every five seconds to check for updates to some information.

 

Thanks for the information. I've since developed a workaround that seems to be working for "push" support: have the client connect to the server running PHP; have the server and client both maximize their timeouts; and then have the server echo and flush whenever something interesting happens.

Link to comment
Share on other sites

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.   Paste as plain text instead

  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...