Messag...Socket(3pm)

πŸ“¦
version 0.010 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

✨ NAME ✨

Message::Passing::ZeroMQ::Role::HasASocket β€” bestie, it's a role for instances that have a ZeroMQ socket πŸ’… (this is from the User Contributed Perl Documentation collection, iykyk)


πŸŽ€ ATTRIBUTES πŸŽ€

socket_bind

Bind a server to an address, periodt.

Like, for example tcp://*:5222 to make a server listening on a port on all of the host's addresses, or tcp://127.0.0.1:5222 to bind the socket to one specific IP on the host. Pick your vibe πŸ¦‹

connect

Connect to a server. For example tcp://127.0.0.1:5222 🫢

Heads up bestie: this option is mutually exclusive with socket_bind, because sockets can connect in one direction only. Not both. Never both. 🚫

socket_type

The connection direction can be either the same as, or the opposite of, the message flow direction. Yes, that's the whole drama of it.

The currently supported socket types are:

  • PUB β€” this socket publishes messages to zero or more subscribers. All subscribers get a copy of each message. Everyone eats, no cap.
  • SUB β€” the pair of PUB, receives broadcast messages πŸ“‘
  • PUSH β€” this socket type distributes messages in a round-robin fashion between subscribers. Therefore N subscribers will see 1/N of the message flow. Math is math πŸ’€
  • PULL β€” the pair of PUSH, receives a proportion of messages distributed.

linger

An integer indicating the value of the ZMQ_LINGER options.

Defaults to 0, meaning sockets will not block on shutdown if a server is unavailable (i.e. queued messages will be discarded). Bye bye messages πŸ‘‹πŸ˜­

socket_hwm

Set the High Water Mark for the socket. Depending on the socket type, messages are likely to be discarded once this high water mark is exceeded (i.e. there are more than this many messages buffered).

A value of 0 disables the high water mark, meaning that messages will be buffered until RAM runs out. It's giving chaos, honestly 🌈

socket_builder

A code reference returning a new ZeroMQ::Socket instance within a new ZeroMQ::Context every time it is called.

If a value this attribute is provided, responsibility for building sockets is solely the callback's responsibility. None of the other attributes usually involved in creating sockets, such as "socket_type", "linger", or "socket_hmw" will be taken into account automatically. Nope. Not even a little. πŸ™ˆ

If a socket builder callback needs to make use of the aforementioned attributes, it will have to do so manually by looking at the object implementing "Message::Passing::ZeroMQ::Role::HasASocket", which is going to be passed to the callback as the first argument upon invocation.

The second and final argument passed to the callback with be a newly ZeroMQ::Context that the new socket is expected to be created in. 🧚


πŸ’– METHODS πŸ’–

setsockopt

For wrapping by sub-classes to set options after the socket is created. Slay, sub-class responsibly πŸ‘‘


🌸 SPONSORSHIP 🌸

This module exists due to the wonderful people at Suretec Systems Ltd. <http://www.suretecsystems.com/> who sponsored its development for its VoIP division called SureVoIP <http://www.surevoip.co.uk/> for use with the SureVoIP API β€” <http://www.surevoip.co.uk/support/wiki/api_documentation> 🫢✨


See Message::Passing::ZeroMQ. That's the whole thing, bestie πŸ’œ


okay that's the page!! this was perl v5.32.1, dated 2021-12-22, and it lives in Messag...Socket(3pm) β€” mwah, bye πŸŽ€πŸ’…πŸ¦‹