Path: utzoo!attcan!uunet!mcsun!ukc!edcastle!aiai!richard From: richard@aiai.ed.ac.uk (Richard Tobin) Newsgroups: comp.lang.c Subject: Re: Signal handling on sockets Keywords: Signals , Sockets Message-ID: <3124@skye.ed.ac.uk> Date: 3 Aug 90 15:47:22 GMT References: <3271@stl.stc.co.uk> Reply-To: richard@aiai.UUCP (Richard Tobin) Distribution: comp.lang.c Organization: AIAI, University of Edinburgh, Scotland Lines: 25 In article <3271@stl.stc.co.uk> "Steve Perryman " writes: >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. Assuming you're using a system with BSD-style signals, you can expect that (1) SIGIO will be blocked during execution of your signal handler and (2) if data arrives while the signal is blocked you will receive precisely one SIGIO when your handler returns, regardless of how many things arrived during the handler. If you're reading the data inside the handler, you should read everything there is, not just one "item". This will mean that you might get a signal after you've read the corresponding data, so be prepared for nothing to be waiting. You can use either select() with a zero timeout or non-blocking i/o for this. -- Richard -- Richard Tobin, JANET: R.Tobin@uk.ac.ed AI Applications Institute, ARPA: R.Tobin%uk.ac.ed@nsfnet-relay.ac.uk Edinburgh University. UUCP: ...!ukc!ed.ac.uk!R.Tobin