[OpenSIPS-Users] mi_datagram - UDP is [still] broken?

Alexander goal81 at gmail.com
Thu Dec 10 10:58:33 CET 2009


Hi all!

I try to get data from OpenSIPS via mi_datagram module.

In opensips.cfg I set:

loadmodule "mi_datagram.so"
modparam("mi_datagram", "socket_name",    "udp:192.168.2.1:5059")
modparam("mi_datagram", "children_count", 3)

Ok, OpenSIPS starts and listens port 5059.

Then I try to get some data with PHP. For example:

$command    = ":uptime:\n\n";

$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
$ret = "";
$from = "";
$port = "";

if ($socket)
{
//    socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array("sec" => 0,
"usec" => 50000));

    socket_sendto($socket, $command, strlen($command), 0, '192.168.2.1',
5059);

    while ((socket_recvfrom($socket, $ret, 10, 0, $from, $port)))
    {
//        echo "Received from $from, port $port\n";
        echo $ret;
    }
}

But this code hangs after receiving first 10 bytes. If I set large buffer
(65535 bytes instead of 10 bytes), whole reply is received properly.

So, is it my bug in PHP script? Or OpenSIPS doesn't work correctly with UDP?
I've read that UDP support in mi_datagram is broken. Is it still true?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.opensips.org/pipermail/users/attachments/20091210/deabe406/attachment.htm 


More information about the Users mailing list