On Fri, 10 Nov 2000, Jon Grimm wrote: > Trying to use the following advice picked up in previous threads: > > Richard B. Johnson wrote: > >I have excellent luck keeping the socket blocking but using > select() with > >a timeout. I have also used an alarm to get out of a blocking call. > Note > >you do NOT have to do a longjump from the routine set by signal(), > just > >a dummy routine, after the timeout, the blocking call will return > with > >the errno set to EINTER. > > > >void dummy (int unused) > >{ > > /* This happens and returns immediately */ > >} > > signal(SIGALRM, dummy); > > alarm(SECONDS); > > status = recv(fd, .....); > > if(status < 0) ... There was an alarm timeout.... > > > >An advantage is that it is "nice" at the kernel level. Your task > will > >sleep until there is either ANY data available or the alarm-clock > went > >off. > > However this did not seem to work on the AF_PACKET socket I'm using. > Should this work?? The alarm fires, but recv() never interrupts. I'll > probably fall > back to a select() w/timeout solution, but was curious to know if this > behaviour > would be expected. siginterrupt(SIGALRM, 1); - Davide - : send the line "unsubscribe linux-net" in the body of a message to majordomo@vger.kernel.org