I am not sure on any of the technical terms, but I think I am describing this in an understandable way.
I am going to write a php script which will listen on a port, and send out data as necessary, i.e. a basic game listening process. There are many places on the web with hints about this, so I think I will be alright there, but any further suggestions on tutorials are welcome.
That is not my question. This is:
What I want to do is have a server where this script is NOT automatically running. What I want instead is when someone fires up the game on their client, it will do a test to see if there is a listening script running already on my server, and if not it will launch it. (I am not sure how to do that yet, but I don't expect that to be too hard. Just send some data to that port and see if there is a response.)
Then when other people join, they will see the script running on the server and use that rather than launching their own.
Are there problems with this idea?
If the first person quits, will the script close down?
Would it be better to let the 'first player' launch the script and put a requirement on the script that it does not shut down. (I.e. the script will run forever until the server gets a restart - basically my server does not mind me running long running scripts, as long as they don't use too much processing, but they don’t allow me to have scripts to start-up if the server is relaunched.)
Would this run-forever script avoid any 'first-player' shutdown problem?
If two people are deemed the 'first player' when they do a check to see if the script is running, but then one of those people launch the script milliseconds before the other, surely this will create two scripts on the server, causing a kind of echo effect for listening. How would I overcome this?
Jon