Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!stc!stl!skp From: skp@stl.stc.co.uk (Steve Perryman ) Newsgroups: comp.lang.c Subject: Signal handling on sockets Keywords: Signals , Sockets Message-ID: <3271@stl.stc.co.uk> Date: 2 Aug 90 10:03:12 GMT Sender: news@stl.stc.co.uk Reply-To: "Steve Perryman " Distribution: comp.lang.c Organization: STC Technology Limited, London Road, Harlow, Essex, UK Lines: 47 I have a signal handling problem I am unable to resolve. I have set up a signal handler to record whenever a socket receives data (using the "signal" operation with the SIGIO/SIGPOLL code) static int trapped ; void trap() { signal(SIGIO,trap) ; trapped++ ; } I have a socket set up to read data from the internet and have used the "fcntl" operation to set the owner process and to allow asynchronous IO so the socket can invoke the signal handler on receipt of data. signal(SIGIO,trap) ; ... ... fcntl(socket,F_SETOWN,getpid()) ; fcntl(socket,F_SETFL,FASYNC) ; ... The problem I have is that my test harness sends n messages to the socket in succession (the real application could receive any number of data items at any time) and the signal handler is invoked ONCE ONLY. After putting in a loop to delay the transmission of each data item, the signal handler was invoked the correct number of times. This suggests a timing/race problem at the receiving end. What I would like to know is how to set the signal handler so it acknowledges every signal regardless of the speed and frequency of receipt of data at the socket (if this is possible). Thanks in advance, Steven Perryman (skp@stl.stc.co.uk)