Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!auspex!guy From: guy@auspex.auspex.com (Guy Harris) Newsgroups: comp.unix.questions Subject: Re: How to do a non-blocking write of more than one char? Message-ID: <2816@auspex.auspex.com> Date: 12 Jan 90 00:11:15 GMT References: <2759@stealth.acf.nyu.edu> <2799@auspex.auspex.com> <5564@stealth.acf.nyu.edu> Distribution: usa Organization: Auspex Systems, Santa Clara Lines: 26 >Can you show me a program that blocks on a write() after select() has >indicated that the descriptor is writable? Sure - a program that writes 50,000 characters on a "write", if the "select()" returns true because there are 2 bytes of buffer space available in the socket. (Or, more generally, a program that writes N characters on a "write", when the "select()" returns true because there are M < N bytes of buffer space left in the socket.) Whether this will actually occur in the real world depends on the value of "N" for any particular write, and the value of "M" for any particular select wakeup; the latter would depend on all sorts of things, like the type of socket, whether you've set SO_SNDBUF, etc.. >Okay, Guy, tell me how I accomplish this: Process A writes data to a >pipe connected to Process B. Process A must not block on its writes, >because it has to handle other descriptors as well. Process B is an >already-written program that assumes that its reads are non-blocking; >it'll take EWOULDBLOCK as a read error and die horribly. I have no idea how you'd accomplish that and, since it's not a problem I've personally run into, it's not exactly high on my list of problems to solve. You have my sympathy, but that's about it.... >C'mon, guys, this is a simple question! And it may have a simple answer like "sorry, you can't do it".