Tom Rogers wrote:
> Hi,
> 
> Tuesday, December 11, 2007, 6:42:18 AM, you wrote:
> RF> Hello,
> 
> Put a usleep(1000) in the listen while() loop and give the cpu a
> break.
> 

This makes me think about asking if you have to short of a timeout on your 
receiving connection?

What are you using to setup your connection?  fsockopen() or 
stream_socket_server() ?

here is a snippet of what I have

<?php

$conn = mysql_connect(...);

if ( $socket = @stream_socket_server('udp://'.LISTEN_IP.':'.LISTEN_PORT,
                $errno, $errstr, STREAM_SERVER_BIND) ) {

        while ( true ) {

                /* Get the exact same packet again, but remove it from the 
buffer this time. */
                $buff = stream_socket_recvfrom($socket, 1024, 0, $remote_ip);

                # do stuff with your incoming data and mysql connection


        }
        fclose($socket);
}

mysql_close($conn);

?>

I don't have a timeout set on the *_recvfrom() call.  I just wait until the 
next connection comes in.

You don't need to use mysql_pconnect(), especially if you are using, what in 
essence is, a daemon.

Just don't open and close the connection constantly, leave it open.

Also, make sure you are not using an array that you are not re-initializing 
through each iteration
of the loop.  If the array keeps getting bigger, PHP might $*%& on itself.  
Always re-initialize
arrays to clean them up.

Hope some of this helps!

-- 
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to