Code Monkey home page Code Monkey logo

zmq.jl's Introduction

NOTE: archival version

This is an old version of ZMQ.jl that existed at the time julia-matlab was created. People have expressed an interest in getting that working again, so this is posted for their benefit.

If you're interested in a "modern" interface to ZeroMQ, see the official ZMQ package.

What follows is the old README.

A Julia interface to ZeroMQ

ZMQ.jl is a [Julia] (http://julialang.org) interface to [ZeroMQ, The Intelligent Transport Layer] (http://zeromq.org).

This codebase has been tested to work with ZeroMQ version 2. Support for version 3 of ZeroMQ is stil incomplete, and is in progress.

Installation

Pkg.add("ZMQ")

Install the ZeroMQ libraries for your OS using your favourite package manager.

Usage

using ZMQ

ctx=ZMQContext(1)
s1=ZMQSocket(ctx, ZMQ_REP)
s2=ZMQSocket(ctx, ZMQ_REQ)

ZMQ.bind(s1, "tcp://*:5555")
ZMQ.connect(s2, "tcp://localhost:5555")

ZMQ.send(s2, ZMQMessage("test request"))
msg = ZMQ.recv(s1)
out=convert(IOStream, msg)
seek(out,0)
#read out::MemIO as usual, eg. read(out,...) or takebuf_string(out)
#or, conveniently, use ASCIIString[msg] to retrieve a string

ZMQ.send(s1, ZMQMessage("test response"))
ZMQ.close(s1)
ZMQ.close(s2)
ZMQ.close(ctx)

RPC

This package includes an RPC mechanism to remotely execute julia functions, possibly from different programming languages. The on-the-wire protocol used for passing messages is the standard Julia serialisation format built into the standard library.

As the functionality matures, this may be split into a separate package.

require("ZMQ/src/RPCJuliaSer")
using RPCJuliaSer
run_server() #using port 5555 by default

In a separate Julia session

julia> require("ZMQ/src/RPCJuliaSer")

julia> using RPCJuliaSer

julia> ctx,req=launch_client()
(ZMQContext(Ptr{Void} @0x0000000103b7a600),ZMQSocket(Ptr{Void} @0x0000000103b6e890))

julia> zmqparse(req, "2+2")
4

zmq.jl's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.