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 6 of 6

Thread: PHP Socket Server

  1. #1

    PHP Socket Server

    Hello everyone!
    So I've been building a prototype flash/php chat application. I used the php resources located here...

    http://www.kirupa.com/developer/flas...s_flash8_4.htm <-- great tutorial, thanks!

    I've since built alot of functions onto the server side script but have a single remaining perplexing dilemma.

    The while loop is only running whenever outside data gets sent to a socket.... here is an example of what I am trying to do...

    In the portion of the code which in the original tutorial said...

    PHP Code:
    if (($client socket_accept($master)) < 0) {
    echo 
    "socket_accept() failed: reason: " .socket_strerror($msgsock). "\n"
    continue;

    else {
    array_push($read_sockets,$client);

    I've added something like....


    PHP Code:
    if (($client socket_accept($master)) < 0) {
    echo 
    "socket_accept() failed: reason: " .socket_strerror($msgsock). "\n"
    continue;

    else {
    $msg"Look what the n00b brought in... errr... welcome to the server\r\n"$client_arr[0]=$client;  
    send_Message($client_arr"Server"$msg);
    array_push($read_sockets,$client);

    Now the problem is... it doesn't send the message right away. It waits until the server has gotten a message from someone and then sends it at that time... (it doesn't matter who sent the message). Instead of sending the message right away like a good little script!

    I've found that (like I said previously) the while loop only runs when data gets sent over a socket. Any ideas? I've tried all sorts of things... including tricking it into running... it's a stubborn script and sees right through me. doh!

    Your help is much appreciated... I can send the complete script to you if you'd like to look at it closer. Help!
    Thanks,
    -Dietrich
    Last edited by dietrich; January 27th, 2008 at 11:12 PM. Reason: (Added PHP code)

  2. #2
    use the [ php ] [ /php ] tags ( no spaces though)
    PHP Code:
     See testing 
    Lies are like children. Their hard work but their worth it because the future depends on them-House.

  3. #3
    oh whoops... sorry! (nice signature btw)

  4. #4
    Thanks.
    Lies are like children. Their hard work but their worth it because the future depends on them-House.

  5. #5
    Ok so, I feel like teh nub! I forgot to include .chr(0) at the end of the message sent to the client. Flash ignores incoming messages that don't end in null.

  6. #6
    Ok, question #2

    Does anyone know what the message generally refers to...

    PHP Code:
    Warningsocket_write() unable to write to socket [32]: Broke pipe in <insert file info here on line 123

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