From: Rick Jones on 1 Jun 2010 15:10 In comp.unix.programmer Bernhard Kuemel <bernhard(a)bksys.at> wrote: > Out of curiosity ... what's the way to use nonblocking writes? > select_tut(2) recommends not to write single bytes at a time. So I try > to write 512K. Doesn't work, because the transmit queue only fits 8K (or > whatever) and I get EAGAIN. select(2) says the write will not block, but > it still won't work, because the queue is still only 8K. So either by > trial and error or by finding out (how?) how big the queue is, I write > 8K. After one byte is sent, select tells me I can write again, but > writing 8K fails because there is only 1 byte free in the queue. So I > either keep busy trying to write 8K until the queue is empty or I write > only 1 byte each time. Doesn't sound so great. I don't *know* that the behaviour will be the same as with a socket, but if it is, when using non-blocking, what happens is the first 512K write reports it took 8K, after which you adjust your pointers and call with the remaining 504K which will elicit the EAGAIN, at which point you might go into select/poll/whatnot, which may indeed come out when there is only 8K of free space, so you write another 8K, update pointers, lather, rinse, repeat... 512K seems like a lot of buffering for a serial port - somehow I doubt that (m)any would have that much. rick jones -- The computing industry isn't as much a game of "Follow The Leader" as it is one of "Ring Around the Rosy" or perhaps "Duck Duck Goose." - Rick Jones these opinions are mine, all mine; HP might not want them anyway... :) feel free to post, OR email to rick.jones2 in hp.com but NOT BOTH...
First
|
Prev
|
Pages: 1 2 3 Prev: Our customer websites are modern, fresh and accessible. Next: We are here for all your events! |