# /* in_wait.c */ /* EMACS_MODES: c !fill */ /* Internet protocol layer for the MIT network system. The following * routines are included: * in_wait Wait for an internet packet to arrive or a * timeout to occur * * Note that use of this package requires the use of the standard I/O * library. */ #include #include #include #include #include in_wait (timeout) /* Wait up to timeout seconds for an internet packet to arrive on * one of our presently open internet connections. If a packet is * presently available the routine will return immediately. Returns * TRUE if a packet is available, and FALSE if a timeout has occurred. * * Arguments: */ register int timeout; /* time to wait before returning */ { long now; /* current time */ long donetime; /* timeout time */ register int retval; /* return value */ time (&now); donetime = now + timeout; if (!(retval = tst_and_clr (&net_avail))) { sysleep ((int)(donetime - now)); retval = tst_and_clr (&net_avail); } return (retval); }