IPC/Sockets and blocking revisited...[THANKS]

Michael Hoefflinger hoff at en.ecn.purdue.edu
Sun Feb 17 09:57:31 AEST 1991


Just wanted to take a moment to thank all the kind folks that took
a minute to write me about the non-blocking socket question I had.
The solution, courtesy of both Les Hill and Mike "Lakermaniac
(not such a good game agains Boston, eh?)" Sullivan:

   flags = fcntl (socket, F_GETFL, 0);
   fcntl (socket, F_SETFL, flags | FNDELAY);

This was indeed the Right Thing (tm) to do, and the Right Time (tm) to do it.

Since I got such a quick and working response on my last question,
I think I will abuse this living user's manual some more:


-->  Question is, how can I execute a getchar() that will return with
     EOF immediately if the user has not typed anything, or with
     the char as soon as it is typed?  The problem is that getchar
     is buffered I/O, and apparently _fillbuf() doesn't exit back to
     getchar until a carriage return is executed.


Appreciate your time.  And thanks again...


Michael Hoefflinger
EE, Purdue University (hoff at ecn.purdue.edu, uxg at fugue.cc.purdue.edu)
"I'm not really a EE grad student, but I played one on TV."



More information about the Comp.unix.programmer mailing list