Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!asuvax!ncar!elroy.jpl.nasa.gov!usc!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!boingo.med.jhu.edu!haven.umd.edu!uvaarpa!murdoch!pine!acl3k From: acl3k@pine.cs.Virginia.EDU (Allan Christian Long) Newsgroups: comp.sys.sgi Subject: Re: ioctl Message-ID: <1991May23.191033.20183@murdoch.acc.Virginia.EDU> Date: 23 May 91 19:10:33 GMT References: <1991May22.143844.6858@cs.dal.ca> <1991May22.161432.25064@murdoch.acc.Virginia.EDU> <105737@sgi.sgi.com> Sender: usenet@murdoch.acc.Virginia.EDU Organization: University of Virginia Computer Science Department Lines: 41 In article <105737@sgi.sgi.com> rpw3@sgi.com (Rob Warnock) writes: >In article <1991May22.161432.25064@murdoch.acc.Virginia.EDU> >acl3k@jade.cs.Virginia.EDU (Allan Christian Long) writes: >+--------------- >| The problem is that the prototype for ioctl is >| int ioctl (int fildes, int request, ...); >| That says what the first and second parameters should be, but I need to >| find out about the rest, which are dependent upon what request is. The >| entry for FIONREAD in ioctl.h is >| #define FIONREAD _IOR(f, 127, int) /* get # bytes to read */ >| I tried changing charToRead to an int, but that didn't help. I need >| documentation for FIONREAD, more than what it says in the header file. >+--------------- > >The third arg for FIONREAD is the *address* of an integer, that is: > > int num_bytes_avail_to_read; > > err = ioctl(file_descriptor, FIONREAD, &num_bytes_avail_to_read); I tried a call exactly like this, but I always got error 22 (invalid argument). [stuff about how # of bytes can change right after the ioctl call and how you can use read() since it returns the number of bytes actually read] If I were writing a program from scratch, this would probably be fine. I may not have mentioned, tho, that what I'm doing is porting a tracker library from SunOS to IRIX (a library that I didn't write). I COULD use read, but it would require some rewiring of the library that would be somewhat difficult. What I'd really like to have is a way to tell how many bytes there are to be read without actually reading them. Thanks to everyone who has responded. I'm still open to suggestions. If I don't get any soon, I'll probably go ahead and rewrite part of the library to use read() and/or select(). - Chris A. Chris Long, Jr. acl3k@virginia.edu If only we could overcome our tools...