Path: utzoo!utgpu!watserv1!watmath!att!att!linac!uwm.edu!cs.utexas.edu!hellgate.utah.edu!peruvian.utah.edu!u-lchoqu From: u-lchoqu%peruvian.utah.edu@cs.utah.edu (Lee Choquette) Newsgroups: comp.sys.mac.programmer Subject: Re: Non-Blocking io (stdin & MacTCP) Summary: use asynchronous File Mgr calls Message-ID: <1990Nov2.194118.29698@hellgate.utah.edu> Date: 3 Nov 90 02:41:18 GMT References: <520@mermaid.Litle.Com> Organization: University of Utah CS Dept Lines: 29 In article <520@mermaid.Litle.Com> kevin@mermaid.Litle.Com (Kevin P. Burke) writes: Am I clueless or does the Mac have no non blocking io? I'm writing some code and don't want to hang around in reads and getlines for ever. Even poll would be nice.... Use the low-level File Manager routines described in Inside Mac II-97-114. You'll have to pass in a parameter block to each routine, and specify asynchronous calling, as in error = PBRead (pBlock, TRUE); If you want to poll, set pBlock.ioCompletion = NULL and poll pBlock.ioResult, waiting until ioResult != 1. Or you can make pBlock.ioCompletion point at a function you want called upon completion of the I/O request, but you must follow the restrictions on page 99 of what routines called at interrupt level may and may not do. The functional difference between this technique and Unix non-blocking I/O, is that in Unix if you get the error EWOULDBLOCK you don't necessarily have to go back later and read from the file. On the Mac you have a pending I/O request, and I can't find in Inside Mac a safe way to cancel that request. Does anyone out there know how to cancel an asynchronous File Manager request? What happens if your application quits before the request completes? Lee Choquette Internet: u-lchoqu@peruvian.utah.edu 3846 Barbara Wy Bitnet: choquette@utahcca Salt Lake City, UT 84124 UUCP: utah-cs!peruvian!u-lchoqu