Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

Results 1 to 7 of 7

Thread: How to: PHP XMLSocketServer

  1. #1

    How to: PHP XMLSocketServer

    I want to create a chat like application with the help of PHP and Flash;

    I have searched a lot and looked the tutorial in kirupa also.
    I understood the working, code; but not the installation and setup;

    Most of them are for windows...

    My hosting service is Linux and my testing service is windows.

    Actually I need a very simple understandable code to test whether it is working in both my services. Then only I expand it to my needs.

    I have a doubt with that first line #!/usr/bin/php -q. How do I know what is to put here.
    And also localhost ip, address in both flash and PHP.


    Please help me. I really need this.. Some simple helps and if it is working I can try to do some extras..

  2. #2
    jwilliam's Avatar
    476
    posts
    An intellectual carrot!
    That first line is called the "shebang." When you try to execute a script, the linux shell will look there to find out how the program should be invoked. In this case, it would see that line and start your script like so:

    /usr/bin/php -q your_script

    The -q stands for "quiet" and suppresses header output. I'm not entirely sure what you mean about the ip addresses. Your socket server will listen on an arbitrary port number, which (I believe) should be a non-standard port... something above 5000. Then your flash client would connect to your domain, or ip address, on that port and the server should hear it (ie, http://www.yourdomain.com:5000). You'll probably have to open that port on your firewall as well.

  3. #3
    Thank you for your reply.

    How can we know whether it is supported by our hosting. In the phpinfo, it says Sockets enabled.

    I just uploaded a php socket script, and opened that file in my browser, the browser shows the first line, the 'shebang'.

    (I already chmodded it to 777.)

  4. #4
    jwilliam's Avatar
    476
    posts
    An intellectual carrot!
    Do you have command line access to your server? Socket servers are daemons by nature, so you'll most likely want to start it from the command line. The idea is that once you start the server, it binds to port x and runs indefinitely, waiting for connection requests on that port. When it receives one, it forks a new process to serve that connection and keeps listening.

  5. #5
    I don't know if I have command line access.

    How do I check? I am using, byethost free hosting, I am using this for testing purposes..

    If this doesn't contain, I will get a new hosting account soon. And after that, how to start this script?

  6. #6
    jwilliam's Avatar
    476
    posts
    An intellectual carrot!
    First make sure the script is executable, then do this:

    $ /path/to/script/socket_server &

    To see if your socket server is still running:

    $ ps -Al | grep socket_server

    ... where "socket_server" is the actual name of your script. Google around a bit and you'll find plenty of info on basic linux shell commands and best practices. Good luck!

  7. #7
    Thank you
    I am trying this..

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012