sleep(x);

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
cmxflash
-


Joined: 11 Dec 2004
Posts: 872

PostPosted: Sun Aug 28, 2005 2:09 pm    Post subject: sleep(x); Reply with quote

Well, I just read about the sleep(x); command on PHPs website.

Here's the script I'm using:
Code:
echo "test";
sleep(2);
echo "test";


If I run it with the PHP-option "php.exe test.php", it works fine, but if I let Abyss run it, it takes 2 secounds, and then "testtest" get written out. Is it possible to get abyss to write "test" when i enter the page, and then write "test" again after 2 seconds?
Back to top View user's profile Send private message
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Sun Aug 28, 2005 7:10 pm    Post subject: Re: sleep(x); Reply with quote

cmxflash wrote:
Well, I just read about the sleep(x); command on PHPs website.

Here's the script I'm using:
Code:
echo "test";
sleep(2);
echo "test";


If I run it with the PHP-option "php.exe test.php", it works fine, but if I let Abyss run it, it takes 2 secounds, and then "testtest" get written out. Is it possible to get abyss to write "test" when i enter the page, and then write "test" again after 2 seconds?


Its something like it'll only send output after x bytes in buffer or something.
It happens if you run it from the command line too, or should, anyway.

It actually waits 2 seconds, but it buffers the output.
If you make something which reads something large (E.G. Something to parse the Swirve data dump.) it'll load it into buffer as it gets it, but you'll see it come in small waves, as the buffer fills up, and clears.
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Mon Aug 29, 2005 12:05 pm    Post subject: Re: sleep(x); Reply with quote

cmxflash,

PHP buffers your output so you'll have to use flush() and other tricks to force it to send it before the sleep() call.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Mon Aug 29, 2005 12:23 pm    Post subject: Reply with quote

Aprelium, could you post a simple example? This functon could help me too but Im not very experienced in php yet...
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Mon Aug 29, 2005 2:11 pm    Post subject: Reply with quote

http://php.net/manual/en/function.flush.php
'Tis pretty self explanitory, just use flush wherever you want to send the currently buffered data. There are other ways, but thats the only one I know of.
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
cmxflash
-


Joined: 11 Dec 2004
Posts: 872

PostPosted: Wed Aug 31, 2005 6:16 am    Post subject: Reply with quote

Example, haven't tested it yet thought:

Code:

<?
echo "test";
flush();
sleep(2);
echo "\nTest again";
?>


Oh and btw, PHP does wait if you use the sleep()-function in the command-line.

Edit: Still the same problem.

Edit again: Got it working =)

Code:
<?
echo "test";
flush();
ob_flush();
flush();
sleep(2);
echo "\nTest again";
?>
Back to top View user's profile Send private message
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Wed Aug 31, 2005 6:50 am    Post subject: Reply with quote

cmxflash wrote:
Oh and btw, PHP does wait if you use the sleep()-function in the command-line.


Was talking about buffering.
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
MVXA
-


Joined: 01 Jan 2005
Posts: 2

PostPosted: Sat Nov 19, 2005 4:19 am    Post subject: Reply with quote

The examples do not work on my Server :/. It
seems that the problem is Flush. This Command
will not work. The Buffer flushes always on Script
end and never before. Can anyone help me, please?
_________________
I'M HERE
Back to top View user's profile Send private message ICQ Number
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Sat Nov 19, 2005 11:45 am    Post subject: Reply with quote

MVXA wrote:
The examples do not work on my Server :/. It
seems that the problem is Flush. This Command
will not work. The Buffer flushes always on Script
end and never before. Can anyone help me, please?


Could you post what you've tried?
Or did you try the exact example above?
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Sat Nov 19, 2005 12:31 pm    Post subject: Reply with quote

This could be down to the version of PHP you are running. It only works with php5 for me.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
MVXA
-


Joined: 01 Jan 2005
Posts: 2

PostPosted: Sat Nov 19, 2005 1:37 pm    Post subject: Reply with quote

Code:
<?php
   ob_end_flush();

   echo "test";
   flush();
   sleep(10);
   echo "\nTest again";
?>

This Code works with PHP 4.4.0 now. It seems, that PHP
has 2 Output Buffer. One you can flush with flush() and
one you can flush with ob_flush(). I have deactivated the
ob_* Buffer and now flush() works. :D

Sorry if I wasted your time :/.
_________________
I'M HERE
Back to top View user's profile Send private message ICQ Number
cmxflash
-


Joined: 11 Dec 2004
Posts: 872

PostPosted: Sat Nov 19, 2005 6:41 pm    Post subject: Reply with quote

This topic is a bit old, and I've already figured out how this works.
Back to top View user's profile Send private message
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Sat Nov 19, 2005 7:10 pm    Post subject: Reply with quote

If you bothered to read the replies since you asked the question you would see we were helping someone else who had a problem with this script.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
cmxflash
-


Joined: 11 Dec 2004
Posts: 872

PostPosted: Sat Nov 19, 2005 7:34 pm    Post subject: Reply with quote

Well, I didn't. I was busy DDoSing P3.
Back to top View user's profile Send private message
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Sat Nov 19, 2005 7:35 pm    Post subject: Reply with quote

cmxflash wrote:
Well, I didn't. I was busy DDoSing P3.



_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Sat Nov 19, 2005 7:36 pm    Post subject: Reply with quote

MonkeyNation wrote:
cmxflash wrote:
Well, I didn't. I was busy DDoSing P3.




LMAO. He is only DDoSing him because he is using apache and not abyss...
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Sat Nov 19, 2005 7:38 pm    Post subject: Reply with quote

The Inquisitor wrote:
LMAO. He is only DDoSing him because he is using apache and not abyss...


That doesn't justify it; true or not.
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Sat Nov 19, 2005 7:39 pm    Post subject: Reply with quote

MonkeyNation wrote:
The Inquisitor wrote:
LMAO. He is only DDoSing him because he is using apache and not abyss...


That doesn't justify it; true or not.


Maybe not but at least he told the truth...
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
cmxflash
-


Joined: 11 Dec 2004
Posts: 872

PostPosted: Sat Nov 19, 2005 7:40 pm    Post subject: Reply with quote

Want me to bring p3net.net down again?
Back to top View user's profile Send private message
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Sat Nov 19, 2005 7:41 pm    Post subject: Reply with quote

cmxflash wrote:
Want me to bring p3net.net down again?


I couldnt care less.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Sat Nov 19, 2005 7:42 pm    Post subject: Reply with quote

cmxflash wrote:
Want me to bring p3net.net down again?



_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group