Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Basically, this script will be running all the time. The way PHP works is that for each script that is being run, a new PHP process is created. Scripts can be run multiple times simultaneously, however they will not be able to directly communicate.</p> <p>You will need to create enother script (or at least a whole new function of this one) to accept the post variables, and then send them to the running version of this script.</p> <p>(Note: I will provide 2 solutions, since 1 is significantly more difficult. Also, there's Semaphore that I've just found, however I am unsure exactly if this suits our needs because I know next to nothing about it <a href="http://php.net/manual/en/book.sem.php" rel="nofollow">http://php.net/manual/en/book.sem.php</a>)</p> <p><strong>Best (But Advanced)</strong></p> <p>The <em>best</em> way I can think of doing this would be to use sockets (particularly on *nix, since sockets are fantastic for IPC [inter process communication]). It's a little difficult, since you're basically create a client/server just to communicate details, then you need to come up with some sort of a protocol for your IPC.</p> <p>I won't code anything up here, but the links that are relevant to this are <a href="http://www.php.net/manual/en/function.socket-create.php" rel="nofollow">http://www.php.net/manual/en/function.socket-create.php</a> http://www.php.net/manual/en/function.socket-bind.php <a href="http://www.php.net/manual/en/function.socket-listen.php" rel="nofollow">http://www.php.net/manual/en/function.socket-listen.php</a> http://www.php.net/manual/en/function.socket-accept.php <a href="http://www.php.net/manual/en/function.socket-connect.php" rel="nofollow">http://www.php.net/manual/en/function.socket-connect.php</a></p> <p>If using this on *nix, I would highly recommend using AF_UNIX as the domain. It's very efficient, and quite a number of applications use it for IPC.</p> <p>Pros: Very robust solution - Highly efficient - Instant (or as close as we can get) communication</p> <p>Cons: - Quite difficult to implement</p> <p><strong>Not As Great (But Still Good)</strong></p> <p>Just use files to communicate the information. Have your bot script check the file every 15 seconds for changes. I would suggest using XML for the data (since simple xml makes xml processing in php well... simple)</p> <p>Things you need to consider would be: How would it react when receiving 2 posts at the same time? (If you just use a flat file or don't account for having multiple entries, this will become a problem). How you find out if a message is new (I'd delete/blank the file right after reading. Note: Not after processing, as someone could post to the form script while you are processing/sending the message)</p> <p>Links: How to use simple xml <a href="http://php.net/manual/en/simplexml.examples-basic.php" rel="nofollow">http://php.net/manual/en/simplexml.examples-basic.php</a> http://au2.php.net/manual/en/book.simplexml.php</p> <p>File related <a href="http://au2.php.net/manual/en/function.file-put-contents.php" rel="nofollow">http://au2.php.net/manual/en/function.file-put-contents.php</a> http://au2.php.net/manual/en/function.file-get-contents.php</p> <p>With that being said, you could also use MySQL/Postgres or some other database back end to deal with the flow of data between scripts.</p> <p>Pros: - Easy to implement</p> <p>Cons: - Slow to transfer data (checks files at given intervals) - Uses external files, which can be deleted/modified my external applications/users</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload