[comp.lang.c] sockets and signals

diamond@tkou02.enet.dec.com (diamond@tkovoa) (08/10/90)

In article <3292@stl.stc.co.uk> "Steve Perryman " <skp@stl.stc.co.uk> writes:

>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.

ANSI C does not provide any way of obtaining information about sockets, or
even to create a socket in the first place.  I have redirected follow-ups
to comp.lang.c because I don't follow the system-specific groups well enough
to know where to put it.  (Sorry.)

One characteristic of signals is that while you are handling a signal, if
more of the same signal arrive, they probably will not even be delivered,
or perhaps one will be delivered.  Nothing prohibits an implementation from
delivering all of them, but most do not do so.

If you want to know how many items are waiting at a socket, you have to
see if there is a socket-related system call to determine this.  Select
can be used to distinguish between zero and non-zero (and I've never had
to know the exact quantity).
-- 
Norman Diamond, Nihon DEC     diamond@tkou02.enet.dec.com
This is me speaking.  If you want to hear the company speak, you need DECtalk.