Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!usc!ucsd!ucbvax!End.Tufts.EDU!icarus From: icarus@End.Tufts.EDU ("Michael J. Saletnik - Local Unix Wizard's Apprentice") Newsgroups: comp.protocols.tcp-ip Subject: Programming question Message-ID: <9010301840.AA04727@sol.end.tufts.edu> Date: 30 Oct 90 18:40:50 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 36 Hi. I've got a question for all the experienced TCP/IP programmers out there. I've been trying to find this in the manuals, but I can't anywhere. I'd greatly appreciate confirmation of my technique and answers to the random questions.. In any case: System: Sun 3/50,3/180 OS: SunOS 4.1 Given a bound and listening socket, can I use fcntl(socket, F_SETFL, FNDELAY); to cause it to be non-blocking, and that way when I call accept() I'll either get back a new socket for a new connection, or errno = EWOULDBLOCK And when do I make the fcntl() call? Given a newly connected socket from an accept(), do I use fcntl(socket, F_SETFL, FASYNC); to enable SIGIO signals, and fcntl(socket, F_SETOWN, getpid()); to point those signals at my process, and signal(SIGIO, handler); to establish my handler? What order should these be? Finally, if my signal handler is declared handler(sig, code, scp, addr) int sig, code; struct sigcontext *scp; char *addr; how can I find out which socket (or file descriptor) caused that signal? Thanks in advance, Michael J. Saletnik icarus@end.tufts.edu