downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

msg_set_queue> <msg_remove_queue
[edit] Last updated: Wed, 22 May 2013

view this page in

msg_send

(PHP 4 >= 4.3.0, PHP 5)

msg_sendEviar un mensaje a una cola de mensajes

Descripción

bool msg_send ( resource $queue , int $msgtype , mixed $message [, bool $serialize = true [, bool $blocking = true [, int &$errorcode ]]] )

msg_send() envía un message del tipo msgtype (DEBE ser mayor que 0) a la cola de mensajes especificada por queue.

Parámetros

queue

msgtype

message

serialize

El parámetro opcional serialize controla el modo de enviar el mensaje dado por message. serialize es por defecto TRUE lo que significa que message es serializado usando el mismo mecanismo que el módulo de sesión antes de ser enviado a la cola. Esto permite matrices y objetos complejos para ser enviados a otros scripts de PHP, o si se está usando el serializador WDDX, para cualquier cliente compatible con WDDX.

blocking

Si el mensaje es demasiado largo para caber en la cola el script esperará hasta que otro proceso lea los mensajes de la cola y libere sufieciente espacio para el mensaje que se va a enviar. Esto se llama bloqueo; se puede prevenir el bloqueo estableciendo el parámetro blocking a FALSE, en cuyo caso msg_send() devolverá inmediatamente FALSE si el mensaje es demasiado grande para la cola, y establecerá el parámetro opcional errorcode a MSG_EAGAIN, indicando que se debería intentar enviar el mensaje de nuevo un poco más tarde.

errorcode

Valores devueltos

Devuelve TRUE en caso de éxito o FALSE en caso de error.

Al finalizar con éxito, la estructura de datos de la cola de mensajes se actualiza como sigue: msg_lspid se establece al ID del proceso de llamada, msg_qnum se incrementa en 1 y msg_stime se establece al momento actual.

Ver también



msg_set_queue> <msg_remove_queue
[edit] Last updated: Wed, 22 May 2013
 
add a note add a note User Contributed Notes msg_send - [5 notes]
up
1
Muffinman
6 months ago
When sending non-complex (serialize = false) messages to a program in C, you need to add the null character to the string (\0). Otherwise the previous message will be partially visible if it is longer than the current message. Took some kind help from comp.lang.php for me to figure that out. While it seems so obvious now, I thought I'd share it here.
up
0
michael dot NO dot SP dot AM dot cordover+php at gmail dot com
3 years ago
After about an hour of debugging I've discovered the meaning of the undocumented "PHP Warning: msg_send(): msgsnd failed: Invalid argument" ($errorcode = 13).

This occurred when the size of $message was larger than msg_qbytes (see msg_stat_queue() for how to determine and change msg_qbytes).
up
0
shepik at yandex dot ru
3 years ago
$msgtype used in msg_send function can be any positive integer.
up
0
bryan-boone at msn dot com
5 years ago
I think it is kinda lame why I cannot find out (easily) explicitly which types of messages are allowed and which ones are not.  Maybe we can start our own little list.  I know that strings work, and arrays do not.
up
0
webmaster at toolshed51 dot com
10 years ago
Sample sending webpage, see msg_receive for matching service

<?php
    $MSGKEY
= 519051;

   
$msg_id = msg_get_queue ($MSGKEY, 0600);

    if (!
msg_send ($msg_id, 1, 'Hi', true, true, $msg_err))
        echo
"Msg not sent because $msg_err\n";
?>

 
show source | credits | sitemap | contact | advertising | mirror sites