home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume20 / etherlib / part01 / src / enetblock.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-10-24  |  980 b   |  35 lines

  1. /* $Id: enetblock.c,v 2.0 89/10/20 19:02:00 dupuy Exp $ */
  2.  
  3. #include <sys/types.h>            /* eniocb (u_char) */
  4. #include <net/enet.h>            /* eniocb */
  5.  
  6. #define ERR (-1)
  7.  
  8. /*
  9.  * If state is false (0), set ethernet file descriptor fd to be non-blocking,
  10.  * else set fd to be blocking. If there is an error, ether_blocking() returns
  11.  * (-1) and the appropriate value is left in errno.  Normal return status
  12.  * zero.
  13.  *
  14.  * We _ought_ to be able to use fcntl like SunOS and Ultrix, but since the enet
  15.  * special device doesn't support the FIONBIO ioctl, we can't.    This is a bug
  16.  * in the enet device driver which should be fixed.  Furthermore, this only
  17.  * prevents blocking on reads (the most common case, admittedly).  Writes to
  18.  * ethernet devices can still block waiting for queue resources.
  19.  */
  20.  
  21. int
  22. ether_blocking (fd, state)
  23. int fd;
  24. int state;
  25. {
  26.     struct eniocb eni;
  27.  
  28.     if (state)
  29.     eni.en_rtout = 0;
  30.     else
  31.     eni.en_rtout = -1;
  32.  
  33.     return (ioctl (fd, EIOCSETP, (char *) &eni));
  34. }
  35.