Jump to content

[SOLVED] msg_receive question..


crichard6069

Recommended Posts

Hi All - I'm very new to PHP but the project I'm doing at work requires it.. with that said, I have a simple question I'm hoping someone can help me with.

 

I have a need to communicate between a C program and PHP and it's looking like a Linux message queue is the way to go. I've written a small C program that puts a message in the queue (and reads from the queue). I've now "advanced" this to putting the message in the queue through the C program and reading it from the queue with a PHP script.

 

Currently I'm running the php script from the shell and it IS reading the message from the queue. However, it seems to be dumping off the first 4 characters of the message. Why is this? If I put a message in the queue from the C app that says "Testing" all I get when I read the queue in PHP is "ing".

 

PHP Code to read the queue:

 

<?

    echo "Starting\n\n";

 

    $MSGKEY = 3;   

    $mqId = msg_get_queue($MSGKEY);

 

    msg_receive($mqId, 0, $msg_type, 2000, $msg, false, 0, $error);

    echo "Message: $msg\n";

    echo "Error: $error\n";

 

    echo "Finished\n";

 

?>

 

I'm just trying to figure out how to get the message in it's entirety. The C app is creating the queue and putting the message there. PHP just needs to attach to it and read the message.

 

Thanks..

Chad

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.