The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

Maximum length of binary/string type option values. (Large enough to hold ZMQ_IDENTITY / ZMQ_LAST_ENDPOINT)

NAME

POEx::ZMQ::FFI::Socket

SYNOPSIS

  # Used internally by POEx::ZMQ

DESCRIPTION

An object representing a ZeroMQ socket; used internally by POEx::ZMQ.

This is essentially a minimalist reimplementation of Dylan Cali's ZMQ::FFI; see ZMQ::FFI for a ZeroMQ FFI implementation intended for use outside POE.

ATTRIBUTES

context

The POEx::ZMQ::FFI::Context object this socket belongs to.

type

The ZeroMQ socket type (as a constant value, see POEx::ZMQ::Constants).

Required at creation time.

soname

The libzmq dynamic library we are using.

Retrieved from our "context" object by default.

METHODS

connect

  $zsock->connect( $endpoint );

See zmq_connect(3)

disconnect

  $zsock->disconnect( $endpoint );

See zmq_disconnect(3)

bind

  $zsock->bind( $endpoint );

See zmq_bind(3)

unbind

  $zsock->unbind( $endpoint );

See zmq_unbind(3)

send

  $zsock->send( $data, $flags );

Send a single-part message.

See zmq_msg_send(3).

send_multipart

Send a multi-part message via ZMQ_SNDMORE.

See zmq_msg_send(3).

recv

  my $msg = $zsock->recv($flags);

Retrieve a single message part.

This could actually be the first part of a multi-part message. Also see "recv_multipart".

recv_multipart

  my $parts = $zsock->recv_multipart;

Retrieve all available parts of a message and return them as a List::Objects::WithUtils::Array.

This is preferable over a "recv", as it handles RCVMORE semantics. (If this was a single-part message, there is one item in the array.)

known_type_for_opt

  my $opt_type = $zsock->known_type_for_opt( $opt_constant );

Returns the type of an option for use with "get_sock_opt" & "set_sock_opt".

get_sock_opt

  my $val = $zsock->get_sock_opt( $opt_constant );
  
  # Or manually specify value type:
  my $val = $zsock->get_sock_opt( $opt_constant, 'int64' );

Retrieves the currently-set value of a ZeroMQ option constant (see POEx::ZMQ::Constants).

See the zmq_getsockopt(3) man page for details regarding option constants and their returned values.

You should typically be able to omit the option value's type -- this class will try to Do The Right Thing. The internal option => type map is exposed via "known_type_for_opt"; it should be reasonably complete. If you have to specify your own value type for a new or missing option, file a bug via http://www.github.com/avenj/poex-zmq|GitHub or RT.

set_sock_opt

  $zsock->set_sock_opt( $opt_constant, $val );
  $zsock->set_sock_opt( $opt_constant, $val, $type );

Set ZeroMQ options; all "get_sock_opt" caveats apply here, also.

See the zmq_setsockopt(3) man page.

get_handle

Returns a file handle (suitable for polling by an event loop such as POE) by performing an fdopen(3) on the file descriptor returned by the ZMQ_FD socket option; see zmq_getsockopt(3) and the http://zguide.zeromq.org|zguide.

get_raw_socket

Returns the raw socket ptr, suitable for use with direct FFI::Raw calls.

has_event_pollin

Checks the ZMQ_EVENTS socket option to determine if the socket is readable.

has_event_pollout

Checks the ZMQ_EVENTS socket option to determine if the socket is writable.

CONSUMES

POEx::ZMQ::FFI::Role::ErrorChecking

AUTHOR

Jon Portnoy <avenj@cobaltirc.org>

Significant portions of this code are inspired by or derived from ZMQ::FFI by Dylan Cali (CPAN: CALID).