Skip to content

Instantly share code, notes, and snippets.

@alfredwesterveld
Created June 28, 2010 07:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alfredwesterveld/455553 to your computer and use it in GitHub Desktop.
Save alfredwesterveld/455553 to your computer and use it in GitHub Desktop.
Simple snippets for http://github.com/alfredwesterveld/java-schedule-broadcaster
<?php
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_URL, "http://localhost:8888/scheduler");
curl_setopt($curl, CURLOPT_WRITEFUNCTION, 'progress');
curl_exec($curl);
curl_close($curl);
function progress($curl, $str) {
print "$str\n";
return strlen($str);
}
<?php
$url = 'http://localhost:8888/scheduler';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
while (true) {
$rnd = rand(1,10000);
$epoch = time() * 1000 + $rnd;
echo $rnd;
curl_setopt($ch,CURLOPT_POSTFIELDS, "message=$rnd&epoch=$epoch");
curl_exec($ch);
sleep(2);
}
curl_close($ch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment