{"id":19973233,"url":"https://github.com/zeromq/perlzmq","last_synced_at":"2025-07-09T05:05:41.857Z","repository":{"id":10979668,"uuid":"13297806","full_name":"zeromq/perlzmq","owner":"zeromq","description":"version agnostic Perl bindings for zeromq","archived":false,"fork":false,"pushed_at":"2023-08-04T11:27:34.000Z","size":426,"stargazers_count":23,"open_issues_count":1,"forks_count":12,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-05-04T02:38:46.499Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zeromq.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-10-03T12:33:25.000Z","updated_at":"2024-07-20T12:53:14.000Z","dependencies_parsed_at":"2024-06-18T15:13:42.719Z","dependency_job_id":"9f242352-5fc2-404c-a670-c85b946288e7","html_url":"https://github.com/zeromq/perlzmq","commit_stats":{"total_commits":390,"total_committers":11,"mean_commits":35.45454545454545,"dds":0.0871794871794872,"last_synced_commit":"484d4a7697ad04b6f79ce1282e586cef725d5308"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"purl":"pkg:github/zeromq/perlzmq","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeromq%2Fperlzmq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeromq%2Fperlzmq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeromq%2Fperlzmq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeromq%2Fperlzmq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zeromq","download_url":"https://codeload.github.com/zeromq/perlzmq/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeromq%2Fperlzmq/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264396629,"owners_count":23601542,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T03:10:44.344Z","updated_at":"2025-07-09T05:05:41.826Z","avatar_url":"https://github.com/zeromq.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ZMQ::FFI [![Build Status](https://api.travis-ci.org/zeromq/perlzmq.svg?branch=master)](https://travis-ci.org/zeromq/perlzmq)\n\n## version agnostic Perl bindings for ØMQ using ffi ##\n\nZMQ::FFI exposes a high level, transparent, OO interface to zeromq independent of the underlying libzmq version.  Where semantics differ, it will dispatch to the appropriate backend for you.  As it uses ffi, there is no dependency on XS or compilation.\n\nZMQ::FFI is implemented using [FFI::Platypus](https://github.com/plicease/FFI-Platypus).\n\n### EXAMPLES ###\n\n#### send/recv ####\n```perl\nuse 5.012;\nuse ZMQ::FFI qw(ZMQ_REQ ZMQ_REP);\n\nmy $endpoint = \"ipc://zmq-ffi-$$\";\nmy $ctx      = ZMQ::FFI-\u003enew();\n\nmy $s1 = $ctx-\u003esocket(ZMQ_REQ);\n$s1-\u003econnect($endpoint);\n\nmy $s2 = $ctx-\u003esocket(ZMQ_REP);\n$s2-\u003ebind($endpoint);\n\n$s1-\u003esend('ohhai');\n\nsay $s2-\u003erecv();\n# ohhai\n```\n\n#### pub/sub ####\n```perl\nuse 5.012;\nuse ZMQ::FFI qw(ZMQ_PUB ZMQ_SUB);\nuse Time::HiRes q(usleep);\n\nmy $endpoint = \"ipc://zmq-ffi-$$\";\nmy $ctx      = ZMQ::FFI-\u003enew();\n\nmy $s = $ctx-\u003esocket(ZMQ_SUB);\nmy $p = $ctx-\u003esocket(ZMQ_PUB);\n\n$s-\u003econnect($endpoint);\n$p-\u003ebind($endpoint);\n\n# all topics\n{\n    $s-\u003esubscribe('');\n\n    until ($s-\u003ehas_pollin) {\n        # compensate for slow subscriber\n        usleep 100_000;\n        $p-\u003esend('ohhai');\n    }\n\n    say $s-\u003erecv();\n    # ohhai\n\n    $s-\u003eunsubscribe('');\n}\n\n# specific topics\n{\n    $s-\u003esubscribe('topic1');\n    $s-\u003esubscribe('topic2');\n\n    until ($s-\u003ehas_pollin) {\n        usleep 100_000;\n        $p-\u003esend('topic1 ohhai');\n        $p-\u003esend('topic2 ohhai');\n    }\n\n    while ($s-\u003ehas_pollin) {\n        say join ' ', $s-\u003erecv();\n        # topic1 ohhai\n        # topic2 ohhai\n    }\n}\n```\n\n#### multipart ####\n```perl\nuse 5.012;\nuse ZMQ::FFI qw(ZMQ_DEALER ZMQ_ROUTER);\n\nmy $endpoint = \"ipc://zmq-ffi-$$\";\nmy $ctx      = ZMQ::FFI-\u003enew();\n\nmy $d = $ctx-\u003esocket(ZMQ_DEALER);\n$d-\u003eset_identity('dealer');\n\nmy $r = $ctx-\u003esocket(ZMQ_ROUTER);\n\n$d-\u003econnect($endpoint);\n$r-\u003ebind($endpoint);\n\n$d-\u003esend_multipart([qw(ABC DEF GHI)]);\n\nsay join ' ', $r-\u003erecv_multipart;\n# dealer ABC DEF GHI\n```\n\n#### nonblocking ####\n```perl\nuse 5.012;\nuse ZMQ::FFI qw(ZMQ_PUSH ZMQ_PULL);\nuse AnyEvent;\nuse EV;\n\nmy $endpoint = \"ipc://zmq-ffi-$$\";\nmy $ctx      = ZMQ::FFI-\u003enew();\nmy @messages = qw(foo bar baz);\n\n\nmy $pull = $ctx-\u003esocket(ZMQ_PULL);\n$pull-\u003ebind($endpoint);\n\nmy $fd = $pull-\u003eget_fd();\n\nmy $recv = 0;\nmy $w = AE::io $fd, 0, sub {\n    while ( $pull-\u003ehas_pollin ) {\n        say $pull-\u003erecv();\n        # foo, bar, baz\n\n        $recv++;\n        if ($recv == 3) {\n            EV::break();\n        }\n    }\n};\n\n\nmy $push = $ctx-\u003esocket(ZMQ_PUSH);\n$push-\u003econnect($endpoint);\n\nmy $sent = 0;\nmy $t;\n$t = AE::timer 0, .1, sub {\n    $push-\u003esend($messages[$sent]);\n\n    $sent++;\n    if ($sent == 3) {\n        undef $t;\n    }\n};\n\nEV::run();\n```\n\n#### specifying versions ####\n```perl\nuse ZMQ::FFI;\n\n# 2.x context\nmy $ctx = ZMQ::FFI-\u003enew( soname =\u003e 'libzmq.so.1' );\nmy ($major, $minor, $patch) = $ctx-\u003eversion;\n\n# 3.x context\nmy $ctx = ZMQ::FFI-\u003enew( soname =\u003e 'libzmq.so.3' );\nmy ($major, $minor, $patch) = $ctx-\u003eversion;\n```\n\n### INSTALL ###\n\n    cpanm -v ZMQ::FFI\n\n### BUILD ###\n\nA docker image is provided with a pre-configured testing environment. To test the module:\n\n    ./docker-run dzil test\n\nTo build a dist tarball:\n\n    ./docker-run dzil build\n\nTo clean build artifacts:\n\n    ./docker-run dzil clean\n\nTests will run against every stable version of zeromq as well as master.  If you would like an interactive shell inside the container run `./docker-shell`\n\nIf you would prefer a native local setup refer to the Dockerfile and translate the setup steps accordingly for your distribution/platform (I personally use the docker container, and this is also how tests run under Travis).\n\n### DOCUMENTATION ###\n\nhttps://metacpan.org/module/ZMQ::FFI\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeromq%2Fperlzmq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzeromq%2Fperlzmq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeromq%2Fperlzmq/lists"}