#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2007
    Posts
    18
    Rep Power
    0

    Implementing mesage queue between client and server. Help!!!


    I need to implement client and server in message queue as follows: when the client send a command to the server via message queue, the server execute the command, and send the output of the command back to the client via message queue. then the client display the message. Here is my question. When the server execute the command, let say "ls", how do you store the output into a char array so that you can send the output back via message queue. I try popen(), system(). None of them give me what I want. They execute the command and send the output to stdout.
  2. #2
  3. /usr/bin/drinking
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2004
    Posts
    719
    Rep Power
    1886
    Have you tried redirecting the output to either a temp file or stdin?
  4. #3
  5. C Neophyte.
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Location
    Melbourne Australia
    Posts
    405
    Rep Power
    46
    What is a "message queue" precisely? Are you using a particular protocol?
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2007
    Posts
    18
    Rep Power
    0
    Originally Posted by fuzzybunny
    What is a "message queue" precisely? Are you using a particular protocol?
    It is a message structure that is part of ipc (inter process communication).

    I am trying to redirect stdout now, but if I can avoid it, that would be great. Any more suggestion?
  8. #5
  9. C Neophyte.
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Location
    Melbourne Australia
    Posts
    405
    Rep Power
    46
    Originally Posted by KingdomHeart
    It is a message structure that is part of ipc (inter process communication).

    I am trying to redirect stdout now, but if I can avoid it, that would be great. Any more suggestion?
    Please show us some code to highlight what you are attempting precisely.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2007
    Posts
    18
    Rep Power
    0
    I figure out the solution. I use popen(). It give me the file descriptor pointer. From there, I can do fgetc to read from the file descriptor pointer and store the buffer array. Thank you very much for the input

IMN logo majestic logo threadwatch logo seochat tools logo