AnyEvent-FastPing
view release on metacpan or search on metacpan
COPYING.GNU view on Meta::CPAN
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
FastPing.xs view on Meta::CPAN
NOW (void)
{
struct timeval tv;
gettimeofday (&tv, 0);
return tv.tv_sec + tv.tv_usec * 1e-6;
}
static void
ssleep (tstamp wait)
{
#if defined (__SVR4) && defined (__sun)
struct timeval tv;
tv.tv_sec = wait;
tv.tv_usec = (wait - tv.tv_sec) * 1e6;
select (0, 0, 0, 0, &tv);
#elif defined(_WIN32)
Sleep ((unsigned long)(delay * 1e3));
FastPing.xs view on Meta::CPAN
free (self);
}
/* like sendto, but retries on failure */
static void
xsendto (int fd, void *buf, size_t len, int flags, void *sa, int salen)
{
tstamp wait = DRAIN_INTERVAL / 2.;
while (sendto (fd, buf, len, flags, sa, salen) < 0 && errno == ENOBUFS)
ssleep (wait *= 2.);
}
// ping current address, return true and increment if more to ping
static int
range_send_ping (RANGE *self, PKT *pkt)
{
// send ping
uint8_t *addr;
int addrlen;
FastPing.xs view on Meta::CPAN
{
tstamp diff = self->next - now;
if (wait < diff)
wait = diff; // global rate limit overrides
else
self->next = range->next; // fast forward
}
if (wait > 0.)
ssleep (wait);
now = NOW ();
ts_to_pkt (&pkt, now);
if (!range_send_ping (range, &pkt))
{
self->ranges [0] = self->ranges [--self->rangecnt];
range_free (range);
}
else
range->next = self->next + range->interval;
downheap (self);
self->next += self->interval;
now = NOW ();
}
ssleep (self->maxrtt);
{
uint16_t id = self->id;
write (thr_res [1], &id, sizeof (id));
}
return 0;
}
( run in 0.623 second using v1.01-cache-2.11-cpan-acf6aa7dc9e )