Thread: Signal Programming

  1. #1
    Registered User cprogrammer_18's Avatar
    Join Date
    Dec 2005
    Posts
    9

    Signal Programming

    Hi All,
    Please help me out for the below problem. Am new to this forum.

    One program(let it be server) will poll the database and update the shared memory. So whenever there is new data available in the shared memory, it has to send signal to the other program(let it be client, this may be in the same machine or diferent machine), then the client will read the data from that shared memory.

    I want to know how to send a signal from the server to the client. I need to send from one program to another porgram. The client program may started up later at any time after the start of server. So tell me how to send the signal from server to client whenever the shared memory is updated.

    Thanks & Regards,
    cprogrammer_18.

  2. #2
    Sr. Software Engineer filker0's Avatar
    Join Date
    Sep 2005
    Location
    West Virginia
    Posts
    235

    Linux IPC

    Your server will need the process ID (PID) of the client. Assuming that the client is not a child process of the server, this will involve setting up a mechanism for the client process to communicate its PID with the server process.

    Look up the man pages for kill(2), sigaction(2), signal(2), sigsetops(2), sigvec(2), and getpid(). Also look at the man page for signal(7), as this will help you better understand signals in Linux.

    For shared memory you will also want to use some sort of semiphore as well to prevent the server from updating the memory while the client is reading from it. Check out the man pages for semget(2), semctl(2), semop(2), and ipc(5) for some clues about this.

    For that matter, read ipc(5) first -- it's an overview of Linux IPC mechanisms. At a Linux terminal window, type
    Code:
    $ man 5 ipc
    I hope this helps.
    Insert obnoxious but pithy remark here

  3. #3
    Registered User
    Join Date
    Mar 2004
    Posts
    19

    Thumbs up

    There are many IPC mechanisms available
    In your case if client and server are running same machine
    then you can choose one of the IPC mechanism from the following
    1.Pipes
    2.shared memory (same you client program can map to this shared memory then it easy to read you need semaphores for this case)
    3.Message Queues
    4.Doors

    If your client and server process running on different machines
    1.Sockets
    2.RPC
    these two techniques will be helpful....

    so u think u r self to choose the method of IPC.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 07-07-2009, 10:05 AM
  2. Signal and exception handling
    By nts in forum C++ Programming
    Replies: 23
    Last Post: 11-15-2007, 02:36 PM
  3. Signal question
    By fnoyan in forum Linux Programming
    Replies: 2
    Last Post: 06-01-2006, 05:46 AM
  4. NAQ: Everything you never wanted to know about CPP
    By evildave in forum C Programming
    Replies: 21
    Last Post: 12-12-2005, 10:56 AM
  5. signal handling
    By trekker in forum C Programming
    Replies: 2
    Last Post: 07-05-2002, 02:52 AM