non-blocking sockets

brnstnd at stealth.acf.nyu.edu brnstnd at stealth.acf.nyu.edu
Sun Apr 15 08:40:04 AEST 1990


In article <28080 at ut-emx.UUCP> ycy at walt.cc.utexas.edu (Joseph Yip) writes:
> I am writing some socket programs. Everything works fine except when I
> want my socket to be NON-BLOCKING.

If the file descriptor may be shared between processes, none of the
techniques for non-blocking I/O mentioned in other messages will work,
because they use fcntls that are per-fd rather than per-process. Under
BSD 4.3 you can use siginterrupt() and signals to customize the amount
of blocking to your taste, whether you're using sockets or not. This is
illustrated by multitee, appearing soon in a source group near you.

If you want asynchronous I/O---i.e., nonblocking I/O plus threads---you
can fork off separate processes, use select/signal/SIGALRM creatively,
or do whatever else suits your taste.

---Dan



More information about the Comp.unix.questions mailing list