sockets and signals (in C)

Steve Perryman skp at stl.stc.co.uk
Wed Aug 8 23:55:23 AEST 1990


Does anyone know of a way to set up a signal handler such that if a flood
of data comes in to a socket, the SIGIO/SIGPOLL (maybe even SIGURG) signal
can invoke a handler fast enough such that a variable can be incremented to
represent the correct number of data items at the socket.

The signal handler will be :

void catch()
{
   signal(SIGIO,catch) ;
   count++ ;
   ...
   ...
}

I've used fcntl to allow the socket to interrupt :

fcntl(sock,F_SETOWN,getpid()) ;
fcntl(sock,F_SETFL,F_ASYNC) ;
...
...

This works but it can't log the correct number of items received if they come
in as bursts of data (5+ items per burst). Can this timing problem be resolved
using SIGIO , or is another way required ???



Thanks in advance,

Steven Perryman
(skp at stl.stc.co.uk)



More information about the Comp.std.c mailing list