Okay, I'm having trouble figuring out how I'm going to do this...

I Script1 is in a while() loop basically keeping the connection alive to an IRC server opened via fsockopen().

I have Script2 that will be called only for sending a command through. This means using the same resource as Script1.

I was in ##php on the FreeNode IRC server (like I always am) but they didn't help me much... Any ideas guys?

Right now I have it doing a sort of "job list" system.

I post each command I want it to send on a separate line and every time the script gets a ping, pong, or someone says something/does something then it retrieves the list of jobs and executes them. This REALLY isn't work and I've tried extremely hard to see if I can get it to execute regardless of something going on, on the server. This is close to impossible but its so far my best solution. Reason this isn't work is because every time it receives an action from the server it goes through the while and then waits for another action. It doesn't continually run through it. This is because its using fgets() to retrieve each packet.

One of the people in ##php suggested I do something like a checkPost() to continually check if it received post-data only to be bashed by me due to the fact that an already running script has already received its headers and is executing the rest of the code... *sigh*... Why am I even in that channel? ...

My main question is this: Is it possible for two separate scripts to share a resource so that one script can send a command and another may listen? (with out storing it in $_SESSION, because it can be worse then what I already have... =/ )

Or is there another method that will work the same way? (easy or hard, I just need a method that gets the job done quick).

I should be able to write out the code if you guys just supply me with ideas. Wink
an open socket should stay open until explicitly closed or the script is terminated. If you are trying to do this on a web server, I don't think it can be done since eventually PHP or Apache will terminate the script - even if its busy. If you aren't doing this on a webserver, then you don't need to worry about keeping the connection open.
Problem already solved, almost forgot about this thread. lol.

The script runs through CLI now and Script2 writes to a file that Script1 reads Razz
Iwas never entirely clear what you were asking here. And wouldn't it be more efficient to just set up a socket between the two scripts?
KermMartian wrote:
Iwas never entirely clear what you were asking here. And wouldn't it be more efficient to just set up a socket between the two scripts?


It would be even more efficient to just use a language that supports threading, lol
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement