NanoMsg::Raw::Message(3pm)

NanoMsg::Raw::Message3pm

Message buffer for nanomsg::raw

Usage

    use NanoMsg::Raw;
    {
        my $msg = nn_allocmsg(3, 0);
        $msg->copy('foo');
        nn_send($sock, $msg);
    }
    {
        nn_recv($sock, my $buf);
        warn $buf;
    }

Overview

Instances of this class represent a message buffer allocated by nanomsg. New empty buffers can be allocated using "nn_allocmsg". Both "nn_recv" and "nn_recvmsg" can be used to allocate buffers initialised with the contents of a received message.

"NanoMsg::Raw::Message"s can be used to send and receive data in a zero-copy fashion.

When using a message instance as a string, its overloading will produce a string containing a copy of the buffer content.

A string pointing to the actual buffer content, without having to create a copy of it, can be obtained by dereferencing the message instance as a scalar.

copy($data)
    $msg->copy('foo');

Copies $data to the beginning of the buffer. If the data is larger than the space allocated for the buffer, an exception will be thrown.

Releases

5 releases since Debian 9 (Stretch); the text changed 4 times.

  1. 9
  2. 10
  3. 11
  4. 12
  5. 13

From libnanomsg-raw-perl 0.10-3+b4 in Debian 13 (Trixie). Parsed by carta from the page's man source.