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
https://forums.phpfreaks.com/topic/81338-solved-msg_receive-question/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.