[comp.unix.questions] signals?

pcb@usl.usl.edu (Peter C. Bahrs) (12/10/89)

I have a server that listens to sockets and processes stuff
as a result of the message.  I am using read, write, connect, accept...
I want to send the server an urgent message from within a client
application.  I want the server to stop what it is doing, handle
the request and continue (interrupt-ish).

Does anyone have any suggestions as how to best approach this problem?
I think I want to set a signal on incoming socket messages?


/*------------Thanks in advance...---------------------------------------+
| Peter C. Bahrs                                                         |
| The USL-NASA Project                                                   |
| Center For Advanced Computer Studies         pcb@gator.usl.edu         |
| University of Southwestern Louisiana                                   |
| Lafayette, LA 70504                318-231-6768                        |
+-----------------------------------------------------------------------*/

bri@boulder.Colorado.EDU (Brian Ellis) (12/11/89)

In article <846@usl.usl.edu> pcb@usl.usl.edu (Peter C. Bahrs) writes:
>I want to send the server an urgent message from within a client
>application.  I want the server to stop what it is doing, handle
>the request and continue (interrupt-ish).
>I think I want to set a signal on incoming socket messages?

	You can arrange to have SIGIO delivered to your server when
	a read is possible from a descriptor (your socket). see fcntl(2).
	Or you could open up a second socket and use out-of-band stuff.

	-brian ellis (bri@boulder.Colorado.EDU)

antony@lbl-csam.arpa (Antony A. Courtney) (12/11/89)

In article <14757@boulder.Colorado.EDU> bri@boulder.Colorado.EDU (Brian Ellis) writes:
>In article <846@usl.usl.edu> pcb@usl.usl.edu (Peter C. Bahrs) writes:
>>I want to send the server an urgent message from within a client
>>application.  I want the server to stop what it is doing, handle
>>the request and continue (interrupt-ish).
>>I think I want to set a signal on incoming socket messages?
>
>	You can arrange to have SIGIO delivered to your server when
>	a read is possible from a descriptor (your socket). see fcntl(2).
>	Or you could open up a second socket and use out-of-band stuff.
>
>	-brian ellis (bri@boulder.Colorado.EDU)


I don't get the impression that this is really what this guy wants.  Maybe I'm
reading things wrong, but I get the impression that he has no problem reading
stuff off the client when the client has something to write to the server. The
issue is how the client can give the server a "kick" of sorts when there is
some reason the server is busy doing other things.  The best way to do this
_IS_ with out-of-band data, but there is no need to set up another socket
specifically for that purpose.  When the client does a send() with OOB data,
the server will get a SIGURG {if it has asked for it}, and will jump to the
user-installed signal handler if one exists.  This signal handler can then do a
recv() off of the socket to get the out-of-band mesage.  I don't really feel
like going into details--look in the UNIX Programmer's manual supplementary
docs, volume 1 for more info.  

"An Advanced 4.3BSD Interprocess Communication Tutorial", Leffler, et al., 
	Berkeley, CA, USENIX association, 1987.

Look in PS1:8-24...

Good luck..

			antony
--
*******************************************************************************
Antony A. Courtney				antony@lbl.gov
Advanced Development Group			ucbvax!lbl-csam.arpa!antony
Lawrence Berkeley Laboratory			AACourtney@lbl.gov