# /* udp_bread.c */ /* EMACS_MODES: c !fill */ /* User Datagram Protocol layer for the MIT network system. The following * routines are included: * udp_bread Blocking read for udp packets */ #include udp_bread (fd, buf, len, timeout) /* Blocking read for udp packets, with a timeout on the read. * Wait up to timeout seconds for a udp packet to arrive on * the specified udp connection, then read it into * the specified buffer. If a packet is presently available the routine * will read it and return immediately. Returns the length of the * received packet in bytes, or 0 if the timeout expires. * * Arguments: */ int fd; /* file descriptor for this conn */ caddr_t buf; /* buffer for received data */ int len; /* buffer size in bytes */ int timeout; /* time to wait before returning */ { if (in_wait (timeout)) return (udp_read (fd, buf, len)); else return (0); }