Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

When I run a msgrcv() and msgsnd() from two different linux consoles then I am able to see the sent message on the msgrcv() console. Logically the same thing should work on two browsers. But it doesn't In the browser, the file recv.pl doesn't even wait for a message whereas on the console when I run recv.pl the system waits till I run send.pl on another console with the particular message qid. Will someone tell me why?

Replies are listed 'Best First'.
(tye)Re: message queueing through Sys V
by tye (Sage) on Sep 06, 2001 at 23:50 UTC

    The call to msgrcv() is failing (that is why it isn't waiting). From your description, you must not be checking for failure and aren't reporting the reason for the failure. Fixing that is the first step.

    If you aren't sure how to fix that, then type "perldoc -f msgrecv" and note "Returns ... false if there is an error". Like most calls, $! will contain the reason:

    if( ! recvmsg( ... ) ) { print "Can't recvmsg(): $!\n"; exit 0; }
    I didn't use die since this is probably a CGI and I don't know if you already have "fatalsToBrowser" turned on.

            - tye (but my friends call me "Tye")
Re: message queueing through Sys V
by trantor (Chaplain) on Sep 06, 2001 at 13:04 UTC

    Please explain!

    Are send.pl and recv.pl script of yours? Can we see the relevant parts?

    Are those scripts meant to be run in a command line environmnent and/or in a CGI environment?

    Do you check whether every system call returns an error? Do you print it in case? Do you use strict and invoke perl with -w?

    How exactly do you run the scritps in a CGI environment? One from the command line (say recv.pl) and the other (say send.pl) invoked as a CGI from a browser?

    -- TMTOWTDI