Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!rutgers!cscnj!paul From: paul@cscnj.csc.COM (Paul Moody) Newsgroups: comp.unix.questions Subject: Re: Socket programming examples wanted Summary: Select? Keywords: socket IPC help Message-ID: <430@cscnj.csc.COM> Date: 19 Oct 89 19:15:22 GMT References: <101@tw-rnd.SanDiego.NCR.COM> Organization: Computer Sciences Corp., Piscataway NJ Lines: 32 In article <101@tw-rnd.SanDiego.NCR.COM>, johnl@tw-rnd.SanDiego.NCR.COM (johnl) writes: > > I would like to get some sample code illustrating the use of sockets > in a client/server model. I am using Internet domain, stream sockets and am > In my example code: > 4. The server (using select) detects the incoming message, > calls accept to get a new file descriptor, > forks a child which calls recv to read the message, > child closes it's (new) socket and dies. I dont know what flavor of tcp/ip you are using, but all three that we work with say 'DONT USE SELECT'. Instead use a blocking accept and set an alarm. eg: /* accept new connections */ timeout = FALSE; signal(SIGALRM,clockwatch); alarm(1); if ((news=accept(s,&newaddr,&newaddrlen)) == -1) { if (timeout == FALSE) abort("accept failed"); } else { makechild(news); } alarm(0); -- Paul Moody UUCP: rutgers!cscnj!paul Computer Sciences Corporation # the opinions expressed are entirely imaginary #