Reference
ZMQ.lib_version
— Functionlib_version()
Get the libzmq version number.
Sockets
The ZMQ Socket type:
ZMQ.Socket
— TypeA ZMQ socket.
ZMQ.Socket
— MethodSocket(ctx::Context, typ::Integer)
Create a socket in a given context.
ZMQ.Socket
— MethodSocket(typ::Integer)
Create a socket of a certain type.
ZMQ.Socket
— MethodSocket(f::Function, args...)
Do-block constructor.
Base.isopen
— FunctionBase.isopen(socket::Socket)
Base.close
— FunctionBase.close(socket::Socket)
Socket
implements the Sockets
interface:
Base.bind
— FunctionSockets.bind(socket::Socket, endpoint::AbstractString)
Bind the socket to an endpoint. Note that the endpoint must be formatted as described here. e.g. tcp://127.0.0.1:42000
.
Sockets.connect
— FunctionSockets.connect(socket::Socket, endpoint::AbstractString)
Connect the socket to an endpoint.
Sockets.recv
— Functionrecv(socket::Socket)
Return a Message
object representing a message received from a ZMQ Socket
(without making a copy of the message data).
recv(socket::Socket, ::Type{T})
Receive a message of type T
(typically a String
, Vector{UInt8}
, or isbits
type) from a ZMQ Socket
. (Makes a copy of the message data; you can alternatively use recv(socket)
to work with zero-copy bytearray-like representation for large messages.)
Sockets.send
— Functionsend(socket::Socket, data; more=false)
Send data
over socket
. A more=true
keyword argument can be passed to indicate that data
is a portion of a larger multipart message. data
can be any isbits
type, a Vector
of isbits
elements, a String
, or a Message
object to perform zero-copy sends of large arrays.
send(socket::Socket, zmsg::Message; more::Bool=false)
Zero-copy version of Sockets.send(socket, data)
using a user-allocated Message
.
ZMQ socket types (note: some of these are aliases; e.g. XREQ = DEALER
):
ZMQ.PAIR
— ConstantPAIR socket.
ZMQ.PUB
— ConstantPUB socket.
ZMQ.SUB
— ConstantSUB socket.
ZMQ.REQ
— ConstantREQ socket.
ZMQ.REP
— ConstantREP socket.
ZMQ.DEALER
— ConstantDEALER socket.
ZMQ.ROUTER
— ConstantROUTER socket.
ZMQ.PULL
— ConstantPULL socket.
ZMQ.PUSH
— ConstantPUSH socket.
ZMQ.XPUB
— ConstantXPUB socket.
ZMQ.XSUB
— ConstantXSUB socket.
ZMQ.XREQ
— ConstantXREQ socket.
This is a deprecated alias for ZMQ.DEALER.
ZMQ.XREP
— ConstantXREP socket.
This is a deprecated alias for ZMQ.ROUTER.
ZMQ.UPSTREAM
— ConstantZMQ.DOWNSTREAM
— ConstantDOWNSTREAM socket.
This is a deprecated alias for ZMQ.PUSH.
Messages
ZMQ.Message
— Typemutable struct Message <: AbstractArray{UInt8, 1}
High-level Message
object for sending/receiving ZMQ messages in shared buffers. As an AbstractArray
, it supports common (non-resizeable) array behaviour.
Examples
julia> using ZMQ
julia> m = Message("foo");
julia> Char(m[1]) # Array indexing
'f': ASCII/Unicode U+0066 (category Ll: Letter, lowercase)
julia> m[end] = Int('g'); # Array assignment
julia> unsafe_string(m) # Conversion to string (only do this if you know the message is a string)
"fog"
julia> IOBuffer(m) # Create a zero-copy IOBuffer
IOBuffer(data=UInt8[...], readable=true, writable=false, seekable=true, append=false, size=3, maxsize=Inf, ptr=1, mark=-1)
ZMQ.Message
— MethodMessage()
Create an empty message (for receive).
ZMQ.Message
— MethodMessage(len::Integer)
Create a message with a given buffer size (for send).
ZMQ.Message
— MethodMessage(origin::Any, m::Ptr{T}, len::Integer) where {T}
Low-level function to create a message (for send) with an existing data buffer, without making a copy. The origin parameter should be the Julia object that is the origin of the data, so that we can hold a reference to it until ZMQ is done with the buffer.
ZMQ.Message
— MethodMessage(m::String)
Create a message with a string as a buffer (for send). Note: the Message now "owns" the string, it must not be resized, or even written to after the message is sent.
ZMQ.Message
— MethodMessage(p::SubString{String})
Create a message with a sub-string as a buffer (for send). Note: the same ownership semantics as for Message(m::String)
apply.
ZMQ.Message
— MethodMessage(origin::Any, m::Ptr{T}, len::Integer) where {T}
Low-level function to create a message (for send) with an existing data buffer, without making a copy. The origin parameter should be the Julia object that is the origin of the data, so that we can hold a reference to it until ZMQ is done with the buffer.
ZMQ.Message
— MethodMessage(io::IOBuffer)
Create a message with an IOBuffer
as a buffer (for send). Note: the same ownership semantics as for Message(m::String)
apply.
ZMQ.isfreed
— Methodisfreed(m::Message)
Check whether zeromq has called our free-function, i.e. whether we are safe to reclaim ownership of any buffer object the Message
was created with.
Context
ZMQ.context
— Functioncontext()
Return the default ZMQ context (of type Context
), initializing it if this has not been done already. (This context is automatically closed when Julia exits.)