Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!watmath!clyde!cbosgd!ihnp4!houxm!vax135!cornell!uw-beaver!tektronix!decvax!genrad!panda!talcott!harvard!seismo!brl-tgr!tgr!ucivax!csuf!dav@ucb-vax.ARPA From: dav@ucb-vax.ARPA Newsgroups: net.unix-wizards Subject: select query Message-ID: <8023@brl-tgr.ARPA> Date: Tue, 5-Feb-85 05:47:26 EST Article-I.D.: brl-tgr.8023 Posted: Tue Feb 5 05:47:26 1985 Date-Received: Sat, 9-Feb-85 04:45:33 EST Sender: news@brl-tgr.ARPA Organization: Ballistic Research Lab Lines: 46 Gee, since no one else has gotten this right yet I guess I'll chip in my two cents worth. >From jsol@BBNCCV.ARPA Tue Jan 29 18:12:59 1985 remote from ucivax >boolean io_haschar(infile) >FILE *infile; >{ > int readfds, nfound; > struct timeval timeout; > > timeout.tv_sec = 10; > timeout.tv_usec = 0; > > readfds = (1<> nfound = select(1, &readfds, 0, 0, &timeout); <----- Vital line! > > if (nfound == 0) > return(FALSE); > if (readfds&(1< return (TRUE); > else > return(FALSE); >} >The problem is: When I call this peice of code, it times out, >claiming infile has no characters ready to read. Examination of the >data stream (with a line monitor) indicates that a character is being >sent to the program, but somehow the program doesn't notice. Your problem has nothing to do with DEC support (but I'm not surprised that everyone jumped on that as a possible reason instead of looking for code errors). Your problem has to do with the first argument to select on the line I flagged above. This argument is documented as "nfds", the number of file descriptors to look at. Your choice of 1 means that select only looks at lines "0 through N-1", or just 0. Of course, your readfds mask tells select to ignore all but "fileno(infile)", which probably isn't 0. I suggest changing that first arg to 32 (or better yet, fileno(infile)+1). This should solve your problem. David L. Markowitz Rockwell International ...!ucbvax!{ucivax,trwrb}!csuf!dav