in reply to While(1) using 100% CPU

Try increasing the TIMEOUT from 0 to say 0.25 .

select ( READ, WRITE, EXCEPTION [, TIMEOUT ] )

     "As you get older three things happen. The first is your memory goes, and I can't remember the other two... " - Sir Norman Wisdom