+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: [PHP] What is wrong with this code?

  1. #1
    XUnreal's Avatar
    XUnreal is offline x10 Sophmore XUnreal is an unknown quantity at this point
    Join Date
    Jun 2005
    Posts
    185

    [PHP] What is wrong with this code?

    I have had a problem trying to make a PHP Socket. The code is below:
    PHP Code:
    <?php
    error_reporting
    (E_ALL);

    /* Allow the script to hang around waiting for connections. */
    set_time_limit(0);

    /* Turn on implicit output flushing so we see what we're getting
     * as it comes in. */
    ob_implicit_flush();

    $address '{REMOVED}';
    $port 551;

    if ((
    $sock socket_create(AF_INETSOCK_STREAMSOL_TCP)) < 0) {
       echo 
    "socket_create() failed: reason: " socket_strerror($sock) . "\n";
    }

    if ((
    $ret socket_bind($sock$address$port)) < 0) {
       echo 
    "socket_bind() failed: reason: " socket_strerror($ret) . "\n";
    }

    if ((
    $ret socket_listen($sock5)) < 0) {
       echo 
    "socket_listen() failed: reason: " socket_strerror($ret) . "\n";
    }

    do {
       if ((
    $msgsock socket_accept($sock)) < 0) {
           echo 
    "socket_accept() failed: reason: " socket_strerror($msgsock) . "\n";
           break;
       }
       do {
         
    explode(" "$buf)
         if (
    $buf[0] == "LVER") {
           
    $lver "0.1"
           
    if ($buf[1] < $lver) {
             
    socket_write($msgsock"OLD""3");
           }
           if (
    $buf[1] > $lver) {
             
    socket_write($msgsock"NEW""3");
           }
           if (
    $buf[1] == $lver) {
             
    socket_write($msgsock"NEW""3");
           }
           }
         }
           if (
    false === ($buf socket_read($msgsock"550"PHP_NORMAL_READ))) {
               echo 
    "socket_read() failed: reason: " socket_strerror($ret) . "\n";
               break 
    2;
           }
           if (!
    $buf trim($buf)) {
               continue;
           }
           if (
    $buf == 'quit') {
               break;
           }
           if (
    $password == '{REMOVED}') {
               
    socket_close($msgsock);
               break 
    2;
           }
       } while (
    true);
       
    socket_close($msgsock);
    } while (
    true);

    socket_close($sock);
    ?>
    NedreN would probably know the answer but if anyone else knows PLEASE reply.

    Thanks in advance,
    - dphiance.

    NOTE: Sorry about that other post, I accidently pressed Tab then Enter before I finished the post... Please delete the old post.
    Last edited by XUnreal; 01-03-2006 at 10:57 AM.


    www.MSN-Mess0rs.be
    We complete MSN's Elite!

  2. #2
    Corey's Avatar
    Corey is offline VPS Migration Professional Corey is a glorious beacon of lightCorey is a glorious beacon of light
    Join Date
    Dec 2004
    Location
    Northfield, NH
    Posts
    17,152

    Re: [PHP] What is wrong with this code?

    Are you getting an error, or ? Any other information ?

    -Corey

  3. #3
    Cynical's Avatar
    Cynical is offline Lord Of The Keys Cynical is an unknown quantity at this point
    Join Date
    Sep 2005
    Location
    Massachusetts, USA
    Posts
    1,746

    Re: [PHP] What is wrong with this code?

    I get this error:
    Quote Originally Posted by ERRORRR'D
    Parse error: parse error, unexpected T_IF in _debug_tmp.php on line 33
    You are missing a ; on line 32 and 35. Then I get this error:
    Quote Originally Posted by ERRORRR'D AGAIN
    Parse error: parse error, unexpected T_IF, expecting T_WHILE in _debug_tmp.php on line 46
    ... which I don't know how to fix.

    EDIT: 200th post! *lame*
    Last edited by Cynical; 01-03-2006 at 11:10 AM.
    Seven: This rule is so underrated, keep your family and business completely separated.

  4. #4
    XUnreal's Avatar
    XUnreal is offline x10 Sophmore XUnreal is an unknown quantity at this point
    Join Date
    Jun 2005
    Posts
    185

    Re: [PHP] What is wrong with this code?

    Doesnt matter, fixed it but I get this now:
    Warning: socket_bind() unable to bind address [98]: Address already in use in /home/xunreal/public_html/socket.php on line 19

    Auvee said it was fine to use Sockets, but I either get that error or "Access Denied".

    Corey, Please help

    Thanks in advance,
    - dark0r.


    www.MSN-Mess0rs.be
    We complete MSN's Elite!

  5. #5
    Corey's Avatar
    Corey is offline VPS Migration Professional Corey is a glorious beacon of lightCorey is a glorious beacon of light
    Join Date
    Dec 2004
    Location
    Northfield, NH
    Posts
    17,152

    Re: [PHP] What is wrong with this code?

    I'm not really familiar with the permissions on that, see if you can find something online regarding it. I don't have time at the moment to look it up

    -Corey

  6. #6
    XUnreal's Avatar
    XUnreal is offline x10 Sophmore XUnreal is an unknown quantity at this point
    Join Date
    Jun 2005
    Posts
    185

    Re: [PHP] What is wrong with this code?

    Ok, thanks Corey. Is Auvee away or something? Hes not on MSN :|


    www.MSN-Mess0rs.be
    We complete MSN's Elite!

  7. #7
    Phil is offline Retired Staff Phil is an unknown quantity at this point
    Join Date
    Aug 2005
    Location
    kingston, Ontairo, Canada
    Posts
    3,672

    Re: [PHP] What is wrong with this code?

    Quote Originally Posted by XUnreal
    Ok, thanks Corey. Is Auvee away or something? Hes not on MSN :|
    He's on a leave from x10 for a while I know that.

  8. #8
    Bryon is offline Administrator Bryon has disabled reputation
    Join Date
    Apr 2005
    Location
    Northfield, NH
    Posts
    7,608

    Re: [PHP] What is wrong with this code?

    I can help you out and attempt to see what is up. I can try in a few minutes, but I cannot promise. It might not be until I get home from school when I get the chance. I'll post back whenever that is.

  9. #9
    flapietoetoe is offline x10 Sophmore flapietoetoe is an unknown quantity at this point
    Join Date
    Aug 2005
    Posts
    113

    Re: [PHP] What is wrong with this code?

    N/m i posted an error fix wich has been fixed already...
    Last edited by flapietoetoe; 01-04-2006 at 01:07 PM.

  10. #10
    Bryon is offline Administrator Bryon has disabled reputation
    Join Date
    Apr 2005
    Location
    Northfield, NH
    Posts
    7,608

    Re: [PHP] What is wrong with this code?

    I don't get it? Do you still need help? (Him?) What?

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Hybrid's HTML Lessons
    By Hybrid in forum Tutorials
    Replies: 18
    Last Post: 11-28-2009, 02:12 PM
  2. Ad Code and Updates
    By Bryon in forum News and Announcements
    Replies: 1
    Last Post: 07-08-2007, 04:14 PM
  3. [PHP] What is wrong with this code?~
    By XUnreal in forum Scripts & 3rd Party Apps
    Replies: 1
    Last Post: 01-03-2006, 10:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers