0

So I want to make a daemon.php file which can open a port on a give ip address and request data from client.php and with the browser to listen/read to earlier pipe (Would that be a problem for the security or not?). I fount this funphp tutorial which seems to be good but is more like a cronjob, I found also function stream-socket-server but can handle only one request and then shuts down, and I really don't know where exactly to put listener.

3
  • That's not the way php is supposed to be working. PHP is really about request/response. There is no natural support for scripts running longer than a single request. Commented Mar 13, 2015 at 8:45
  • @pintxo No, there is a way, the PHP Built--In Server : it is created especially to help developers and for testing purposes only... Commented Mar 13, 2015 at 8:57
  • but are so many function there like flush for example who is able to respond to server and also to maintain the connection open Commented Mar 13, 2015 at 8:58

1 Answer 1

1

You can use the PHP Built-In Server

  • Add PHP to your PATH environment variable
  • Start your server on a given port, ex: php -S localhost:8000 OR
  • Start with a router script, ex: php -S localhost:8000 rt.php
  • Now, just open your browser and type; localhost:8000

    Sign up to request clarification or add additional context in comments.

    3 Comments

    @JohniDevo, sorry i don't understand your question
    The -S from the php -S localhost:8000 rt.php is also a scipt and contains what i write earlier in my question
    The -S it is an option that means 'START' i think, in your case you have to do like this : php -S localhost:8000 daemon.php

    Your Answer

    By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.