zmq4: github.com/pebbe/zmq4 Index | Files | Directories

package zmq4

import "github.com/pebbe/zmq4"

A Go interface to ZeroMQ (zmq, 0mq) version 4.

For ZeroMQ version 3, see: http://github.com/pebbe/zmq3

For ZeroMQ version 2, see: http://github.com/pebbe/zmq2

http://www.zeromq.org/

See also the wiki: https://github.com/pebbe/zmq4/wiki

A note on the use of a context:

This package provides a default context. This is what will be used by the functions without a context receiver, that create a socket or manipulate the context. Package developers that import this package should probably not use the default context with its associated functions, but create their own context(s). See: type Context.

Index

Package Files

auth.go ctxoptions_unix.go doc.go errors.go polling.go reactor.go socketget.go socketget_unix.go socketset.go utils.go zmq4.go

Constants

const (

    // On Windows platform some of the standard POSIX errnos are not defined.
    EADDRINUSE      = Errno(C.EADDRINUSE)
    EADDRNOTAVAIL   = Errno(C.EADDRNOTAVAIL)
    EAFNOSUPPORT    = Errno(C.EAFNOSUPPORT)
    ECONNABORTED    = Errno(C.ECONNABORTED)
    ECONNREFUSED    = Errno(C.ECONNREFUSED)
    ECONNRESET      = Errno(C.ECONNRESET)
    EHOSTUNREACH    = Errno(C.EHOSTUNREACH)
    EINPROGRESS     = Errno(C.EINPROGRESS)
    EMSGSIZE        = Errno(C.EMSGSIZE)
    ENETDOWN        = Errno(C.ENETDOWN)
    ENETRESET       = Errno(C.ENETRESET)
    ENETUNREACH     = Errno(C.ENETUNREACH)
    ENOBUFS         = Errno(C.ENOBUFS)
    ENOTCONN        = Errno(C.ENOTCONN)
    ENOTSOCK        = Errno(C.ENOTSOCK)
    ENOTSUP         = Errno(C.ENOTSUP)
    EPROTONOSUPPORT = Errno(C.EPROTONOSUPPORT)
    ETIMEDOUT       = Errno(C.ETIMEDOUT)

    // Native 0MQ error codes.
    EFSM           = Errno(C.EFSM)
    EMTHREAD       = Errno(C.EMTHREAD)
    ENOCOMPATPROTO = Errno(C.ENOCOMPATPROTO)
    ETERM          = Errno(C.ETERM)
)
const (
    MaxSocketsDflt = int(C.ZMQ_MAX_SOCKETS_DFLT)
    IoThreadsDflt  = int(C.ZMQ_IO_THREADS_DFLT)
)
const (
    // Constants for NewSocket()
    // See: http://api.zeromq.org/4-1:zmq-socket#toc3
    REQ    = Type(C.ZMQ_REQ)
    REP    = Type(C.ZMQ_REP)
    DEALER = Type(C.ZMQ_DEALER)
    ROUTER = Type(C.ZMQ_ROUTER)
    PUB    = Type(C.ZMQ_PUB)
    SUB    = Type(C.ZMQ_SUB)
    XPUB   = Type(C.ZMQ_XPUB)
    XSUB   = Type(C.ZMQ_XSUB)
    PUSH   = Type(C.ZMQ_PUSH)
    PULL   = Type(C.ZMQ_PULL)
    PAIR   = Type(C.ZMQ_PAIR)
    STREAM = Type(C.ZMQ_STREAM)
)
const (
    // Flags for (*Socket)Send(), (*Socket)Recv()
    // For Send, see: http://api.zeromq.org/4-1:zmq-send#toc2
    // For Recv, see: http://api.zeromq.org/4-1:zmq-msg-recv#toc2
    DONTWAIT = Flag(C.ZMQ_DONTWAIT)
    SNDMORE  = Flag(C.ZMQ_SNDMORE)
)
const (
    // Flags for (*Socket)Monitor() and (*Socket)RecvEvent()
    // See: http://api.zeromq.org/4-3:zmq-socket-monitor#toc3
    EVENT_ALL                        = Event(C.ZMQ_EVENT_ALL)
    EVENT_CONNECTED                  = Event(C.ZMQ_EVENT_CONNECTED)
    EVENT_CONNECT_DELAYED            = Event(C.ZMQ_EVENT_CONNECT_DELAYED)
    EVENT_CONNECT_RETRIED            = Event(C.ZMQ_EVENT_CONNECT_RETRIED)
    EVENT_LISTENING                  = Event(C.ZMQ_EVENT_LISTENING)
    EVENT_BIND_FAILED                = Event(C.ZMQ_EVENT_BIND_FAILED)
    EVENT_ACCEPTED                   = Event(C.ZMQ_EVENT_ACCEPTED)
    EVENT_ACCEPT_FAILED              = Event(C.ZMQ_EVENT_ACCEPT_FAILED)
    EVENT_CLOSED                     = Event(C.ZMQ_EVENT_CLOSED)
    EVENT_CLOSE_FAILED               = Event(C.ZMQ_EVENT_CLOSE_FAILED)
    EVENT_DISCONNECTED               = Event(C.ZMQ_EVENT_DISCONNECTED)
    EVENT_MONITOR_STOPPED            = Event(C.ZMQ_EVENT_MONITOR_STOPPED)
    EVENT_HANDSHAKE_FAILED_NO_DETAIL = Event(C.ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL)
    EVENT_HANDSHAKE_SUCCEEDED        = Event(C.ZMQ_EVENT_HANDSHAKE_SUCCEEDED)
    EVENT_HANDSHAKE_FAILED_PROTOCOL  = Event(C.ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL)
    EVENT_HANDSHAKE_FAILED_AUTH      = Event(C.ZMQ_EVENT_HANDSHAKE_FAILED_AUTH)
)
const (
    // Flags for (*Socket)GetEvents()
    // See: http://api.zeromq.org/4-1:zmq-getsockopt#toc8
    POLLIN  = State(C.ZMQ_POLLIN)
    POLLOUT = State(C.ZMQ_POLLOUT)
)
const (
    // Constants for (*Socket)GetMechanism()
    // See: http://api.zeromq.org/4-1:zmq-getsockopt#toc22
    NULL   = Mechanism(C.ZMQ_NULL)
    PLAIN  = Mechanism(C.ZMQ_PLAIN)
    CURVE  = Mechanism(C.ZMQ_CURVE)
    GSSAPI = Mechanism(C.ZMQ_GSSAPI)
)
const CURVE_ALLOW_ANY = "*"

Variables

var (
    ErrorContextClosed         = errors.New("Context is closed")
    ErrorSocketClosed          = errors.New("Socket is closed")
    ErrorMoreExpected          = errors.New("More expected")
    ErrorNotImplemented405     = errors.New("Not implemented, requires 0MQ version 4.0.5")
    ErrorNotImplemented41      = errors.New("Not implemented, requires 0MQ version 4.1")
    ErrorNotImplemented42      = errors.New("Not implemented, requires 0MQ version 4.2")
    ErrorNotImplementedWindows = errors.New("Not implemented on Windows")
    ErrorNoSocket              = errors.New("No such socket")
)

func AuthAllow Uses

func AuthAllow(domain string, addresses ...string)

Allow (whitelist) some addresses for a domain.

An address can be a single IP address, or an IP address and mask in CIDR notation.

For NULL, all clients from these addresses will be accepted.

For PLAIN and CURVE, they will be allowed to continue with authentication.

You can call this method multiple times to whitelist multiple IP addresses.

If you whitelist a single address for a domain, any non-whitelisted addresses for that domain are treated as blacklisted.

Use domain "*" for all domains.

For backward compatibility: if domain can be parsed as an IP address, it will be interpreted as another address, and it and all remaining addresses will be added to all domains.

func AuthCurveAdd Uses

func AuthCurveAdd(domain string, pubkeys ...string)

Add public user keys for CURVE authentication for a given domain.

To cover all domains, use "*".

Public keys are in Z85 printable text format.

To allow all client keys without checking, specify CURVE_ALLOW_ANY for the key.

func AuthCurvePublic Uses

func AuthCurvePublic(z85SecretKey string) (z85PublicKey string, err error)

Helper function to derive z85 public key from secret key

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

func AuthCurveRemove Uses

func AuthCurveRemove(domain string, pubkeys ...string)

Remove user keys from CURVE authentication for a given domain.

func AuthCurveRemoveAll Uses

func AuthCurveRemoveAll(domain string)

Remove all user keys from CURVE authentication for a given domain.

func AuthDeny Uses

func AuthDeny(domain string, addresses ...string)

Deny (blacklist) some addresses for a domain.

An address can be a single IP address, or an IP address and mask in CIDR notation.

For all security mechanisms, this rejects the connection without any further authentication.

Use either a whitelist for a domain, or a blacklist for a domain, not both. If you define both a whitelist and a blacklist for a domain, only the whitelist takes effect.

Use domain "*" for all domains.

For backward compatibility: if domain can be parsed as an IP address, it will be interpreted as another address, and it and all remaining addresses will be added to all domains.

func AuthMetaBlob Uses

func AuthMetaBlob(key, value string) (blob []byte, err error)

This encodes a key/value pair into the format used by a ZAP handler.

Returns an error if key is more then 255 characters long.

func AuthPlainAdd Uses

func AuthPlainAdd(domain, username, password string)

Add a user for PLAIN authentication for a given domain.

Set `domain` to "*" to apply to all domains.

func AuthPlainRemove Uses

func AuthPlainRemove(domain string, usernames ...string)

Remove users from PLAIN authentication for a given domain.

func AuthPlainRemoveAll Uses

func AuthPlainRemoveAll(domain string)

Remove all users from PLAIN authentication for a given domain.

func AuthSetMetadataHandler Uses

func AuthSetMetadataHandler(
    handler func(
        version, request_id, domain, address, identity, mechanism string, credentials ...string) (metadata map[string]string))

This function sets the metadata handler that is called by the ZAP handler to retrieve key/value properties that should be set on reply messages in case of a status code "200" (succes).

Default properties are `Socket-Type`, which is already set, and `Identity` and `User-Id` that are empty by default. The last two can be set, and more properties can be added.

The `User-Id` property is used for the `user id` frame of the reply message. All other properties are stored in the `metadata` frame of the reply message.

The default handler returns an empty map.

For the meaning of the handler arguments, and other details, see: http://rfc.zeromq.org/spec:27#toc10

func AuthSetVerbose Uses

func AuthSetVerbose(verbose bool)

Enable verbose tracing of commands and activity.

func AuthStart Uses

func AuthStart() (err error)

Start authentication.

Note that until you add policies, all incoming NULL connections are allowed (classic ZeroMQ behaviour), and all PLAIN and CURVE connections are denied.

func AuthStop Uses

func AuthStop()

Stop authentication.

func Error Uses

func Error(e int) string

Get 0MQ error message string.

func GetBlocky Uses

func GetBlocky() (bool, error)

Returns the blocky setting in the default context.

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

func GetIoThreads Uses

func GetIoThreads() (int, error)

Returns the size of the 0MQ thread pool in the default context.

func GetIpv6 Uses

func GetIpv6() (bool, error)

Returns the IPv6 option in the default context.

func GetMaxMsgsz Uses

func GetMaxMsgsz() (int, error)

Returns the maximum message size in the default context.

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

func GetMaxSockets Uses

func GetMaxSockets() (int, error)

Returns the maximum number of sockets allowed in the default context.

func HasCurve Uses

func HasCurve() bool

Returns false for ZeroMQ version < 4.1.0

Else: returns true if the library supports the CURVE security mechanism

func HasGssapi Uses

func HasGssapi() bool

Returns false for ZeroMQ version < 4.1.0

Else: returns true if the library supports the GSSAPI security mechanism

func HasIpc Uses

func HasIpc() bool

Returns false for ZeroMQ version < 4.1.0

Else: returns true if the library supports the ipc:// protocol

func HasNorm Uses

func HasNorm() bool

Returns false for ZeroMQ version < 4.1.0

Else: returns true if the library supports the norm:// protocol

func HasPgm Uses

func HasPgm() bool

Returns false for ZeroMQ version < 4.1.0

Else: returns true if the library supports the pgm:// protocol

func HasTipc Uses

func HasTipc() bool

Returns false for ZeroMQ version < 4.1.0

Else: returns true if the library supports the tipc:// protocol

func NewCurveKeypair Uses

func NewCurveKeypair() (z85_public_key, z85_secret_key string, err error)

Generate a new CURVE keypair

See: http://api.zeromq.org/4-1:zmq-curve-keypair#toc2

func Proxy Uses

func Proxy(frontend, backend, capture *Socket) error

Start built-in ØMQ proxy

See: http://api.zeromq.org/4-1:zmq-proxy#toc2

func ProxySteerable Uses

func ProxySteerable(frontend, backend, capture, control *Socket) error

Start built-in ØMQ proxy with PAUSE/RESUME/TERMINATE control flow

Returns ErrorNotImplemented405 with ZeroMQ version < 4.0.5

See: http://api.zeromq.org/4-1:zmq-proxy-steerable#toc2

func SetBlocky Uses

func SetBlocky(i bool) error

Sets the blocky behavior in the default context.

See: http://api.zeromq.org/4-2:zmq-ctx-set#toc3

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

func SetIoThreads Uses

func SetIoThreads(n int) error

Specifies the size of the 0MQ thread pool to handle I/O operations in the default context. If your application is using only the inproc transport for messaging you may set this to zero, otherwise set it to at least one. This option only applies before creating any sockets.

Default value: 1

func SetIpv6 Uses

func SetIpv6(i bool) error

Sets the IPv6 value for all sockets created in the default context from this point onwards. A value of true means IPv6 is enabled, while false means the socket will use only IPv4. When IPv6 is enabled, a socket will connect to, or accept connections from, both IPv4 and IPv6 hosts.

Default value: false

func SetMaxMsgsz Uses

func SetMaxMsgsz(n int) error

Set maximum message size in the default context.

Default value: INT_MAX

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

func SetMaxSockets Uses

func SetMaxSockets(n int) error

Sets the maximum number of sockets allowed in the default context.

Default value: 1024

func SetThreadPriority Uses

func SetThreadPriority(n int) error

Sets scheduling priority for default context’s thread pool.

This option requires ZeroMQ version 4.1, and is not available on Windows.

Supported values for this option depend on chosen scheduling policy. Details can be found in sched.h file, or at http://man7.org/linux/man-pages/man2/sched_setscheduler.2.html

This option only applies before creating any sockets on the context.

Default value: -1

Returns ErrorNotImplemented41 with ZeroMQ version < 4.1

Returns ErrorNotImplementedWindows on Windows

func SetThreadSchedPolicy Uses

func SetThreadSchedPolicy(n int) error

Sets the scheduling policy for default context’s thread pool.

This option requires ZeroMQ version 4.1, and is not available on Windows.

Supported values for this option can be found in sched.h file, or at http://man7.org/linux/man-pages/man2/sched_setscheduler.2.html

This option only applies before creating any sockets on the context.

Default value: -1

Returns ErrorNotImplemented41 with ZeroMQ version < 4.1

Returns ErrorNotImplementedWindows on Windows

func Term Uses

func Term() error

Terminates the default context.

For linger behavior, see: http://api.zeromq.org/4-1:zmq-ctx-term

func Version Uses

func Version() (major, minor, patch int)

Report 0MQ library version.

func Z85decode Uses

func Z85decode(s string) string

Decode a binary key from Z85 printable text

See: http://api.zeromq.org/4-1:zmq-z85-decode

func Z85encode Uses

func Z85encode(data string) string

Encode a binary key as Z85 printable text

See: http://api.zeromq.org/4-1:zmq-z85-encode

type Context Uses

type Context struct {
    // contains filtered or unexported fields
}

A context that is not the default context.

func NewContext Uses

func NewContext() (ctx *Context, err error)

Create a new context.

func (*Context) GetBlocky Uses

func (ctx *Context) GetBlocky() (bool, error)

Returns the blocky setting.

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

func (*Context) GetIoThreads Uses

func (ctx *Context) GetIoThreads() (int, error)

Returns the size of the 0MQ thread pool.

func (*Context) GetIpv6 Uses

func (ctx *Context) GetIpv6() (bool, error)

Returns the IPv6 option.

func (*Context) GetMaxMsgsz Uses

func (ctx *Context) GetMaxMsgsz() (int, error)

Returns the maximum message size.

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

func (*Context) GetMaxSockets Uses

func (ctx *Context) GetMaxSockets() (int, error)

Returns the maximum number of sockets allowed.

func (*Context) NewSocket Uses

func (ctx *Context) NewSocket(t Type) (soc *Socket, err error)

Create 0MQ socket in the given context.

WARNING: The Socket is not thread safe. This means that you cannot access the same Socket from different goroutines without using something like a mutex.

For a description of socket types, see: http://api.zeromq.org/4-1:zmq-socket#toc3

func (*Context) SetBlocky Uses

func (ctx *Context) SetBlocky(i bool) error

Sets the blocky behavior.

See: http://api.zeromq.org/4-2:zmq-ctx-set#toc3

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

func (*Context) SetIoThreads Uses

func (ctx *Context) SetIoThreads(n int) error

Specifies the size of the 0MQ thread pool to handle I/O operations. If your application is using only the inproc transport for messaging you may set this to zero, otherwise set it to at least one. This option only applies before creating any sockets.

Default value: 1

func (*Context) SetIpv6 Uses

func (ctx *Context) SetIpv6(i bool) error

Sets the IPv6 value for all sockets created in the context from this point onwards. A value of true means IPv6 is enabled, while false means the socket will use only IPv4. When IPv6 is enabled, a socket will connect to, or accept connections from, both IPv4 and IPv6 hosts.

Default value: false

func (*Context) SetMaxMsgsz Uses

func (ctx *Context) SetMaxMsgsz(n int) error

Set maximum message size.

Default value: INT_MAX

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

func (*Context) SetMaxSockets Uses

func (ctx *Context) SetMaxSockets(n int) error

Sets the maximum number of sockets allowed.

Default value: 1024

func (*Context) SetThreadPriority Uses

func (ctx *Context) SetThreadPriority(n int) error

Sets scheduling priority for internal context’s thread pool.

This option requires ZeroMQ version 4.1, and is not available on Windows.

Supported values for this option depend on chosen scheduling policy. Details can be found in sched.h file, or at http://man7.org/linux/man-pages/man2/sched_setscheduler.2.html

This option only applies before creating any sockets on the context.

Default value: -1

Returns ErrorNotImplemented41 with ZeroMQ version < 4.1

Returns ErrorNotImplementedWindows on Windows

func (*Context) SetThreadSchedPolicy Uses

func (ctx *Context) SetThreadSchedPolicy(n int) error

Sets the scheduling policy for internal context’s thread pool.

This option requires ZeroMQ version 4.1, and is not available on Windows.

Supported values for this option can be found in sched.h file, or at http://man7.org/linux/man-pages/man2/sched_setscheduler.2.html

This option only applies before creating any sockets on the context.

Default value: -1

Returns ErrorNotImplemented41 with ZeroMQ version < 4.1

Returns ErrorNotImplementedWindows on Windows

func (*Context) Term Uses

func (ctx *Context) Term() error

Terminates the context.

For linger behavior, see: http://api.zeromq.org/4-1:zmq-ctx-term

type Errno Uses

type Errno uintptr

An Errno is an unsigned number describing an error condition as returned by a call to ZeroMQ. It implements the error interface. The number is either a standard system error, or an error defined by the C library of ZeroMQ.

func AsErrno Uses

func AsErrno(err error) Errno

Convert error to Errno.

Example usage:

switch AsErrno(err) {

case zmq.Errno(syscall.EINTR):
    // standard system error

    // call was interrupted

case zmq.ETERM:
    // error defined by ZeroMQ

    // context was terminated

}

See also: examples/interrupt.go

func (Errno) Error Uses

func (errno Errno) Error() string

Return Errno as string.

type Event Uses

type Event int

Used by (*Socket)Monitor() and (*Socket)RecvEvent()

func (Event) String Uses

func (e Event) String() string

Socket event as string.

type Flag Uses

type Flag int

Used by (*Socket)Send() and (*Socket)Recv()

func (Flag) String Uses

func (f Flag) String() string

Socket flag as string.

type Mechanism Uses

type Mechanism int

Specifies the security mechanism, used by (*Socket)GetMechanism()

func (Mechanism) String Uses

func (m Mechanism) String() string

Security mechanism as string.

type Polled Uses

type Polled struct {
    Socket *Socket // socket with matched event(s)
    Events State   // actual matched event(s)
}

Return type for (*Poller)Poll

type Poller Uses

type Poller struct {
    // contains filtered or unexported fields
}

func NewPoller Uses

func NewPoller() *Poller

Create a new Poller

func (*Poller) Add Uses

func (p *Poller) Add(soc *Socket, events State) int

Add items to the poller

Events is a bitwise OR of zmq.POLLIN and zmq.POLLOUT

Returns the id of the item, which can be used as a handle to (*Poller)Update and as an index into the result of (*Poller)PollAll

func (*Poller) Poll Uses

func (p *Poller) Poll(timeout time.Duration) ([]Polled, error)

Input/output multiplexing

If timeout < 0, wait forever until a matching event is detected

Only sockets with matching socket events are returned in the list.

Example:

poller := zmq.NewPoller()
poller.Add(socket0, zmq.POLLIN)
poller.Add(socket1, zmq.POLLIN)
//  Process messages from both sockets
for {
    sockets, _ := poller.Poll(-1)
    for _, socket := range sockets {
        switch s := socket.Socket; s {
        case socket0:
            msg, _ := s.Recv(0)
            //  Process msg
        case socket1:
            msg, _ := s.Recv(0)
            //  Process msg
        }
    }
}

func (*Poller) PollAll Uses

func (p *Poller) PollAll(timeout time.Duration) ([]Polled, error)

This is like (*Poller)Poll, but it returns a list of all sockets, in the same order as they were added to the poller, not just those sockets that had an event.

For each socket in the list, you have to check the Events field to see if there was actually an event.

When error is not nil, the return list contains no sockets.

func (*Poller) Remove Uses

func (p *Poller) Remove(id int) error

Remove a socket from the poller

Returns ErrorNoSocket if the id was out of range

func (*Poller) RemoveBySocket Uses

func (p *Poller) RemoveBySocket(soc *Socket) error

Remove a socket from the poller

Returns ErrorNoSocket if the socket didn't match

func (*Poller) String Uses

func (p *Poller) String() string

Poller as string.

func (*Poller) Update Uses

func (p *Poller) Update(id int, events State) (previous State, err error)

Update the events mask of a socket in the poller

Replaces the Poller's bitmask for the specified id with the events parameter passed

Returns the previous value, or ErrorNoSocket if the id was out of range

func (*Poller) UpdateBySocket Uses

func (p *Poller) UpdateBySocket(soc *Socket, events State) (previous State, err error)

Update the events mask of a socket in the poller

Replaces the Poller's bitmask for the specified socket with the events parameter passed

Returns the previous value, or ErrorNoSocket if the socket didn't match

type Reactor Uses

type Reactor struct {
    // contains filtered or unexported fields
}

func NewReactor Uses

func NewReactor() *Reactor

Create a reactor to mix the handling of sockets and channels (timers or other channels).

Example:

reactor := zmq.NewReactor()
reactor.AddSocket(socket1, zmq.POLLIN, socket1_handler)
reactor.AddSocket(socket2, zmq.POLLIN, socket2_handler)
reactor.AddChannelTime(time.Tick(time.Second), 1, ticker_handler)
reactor.Run(time.Second)

func (*Reactor) AddChannel Uses

func (r *Reactor) AddChannel(ch <-chan interface{}, limit int, handler func(interface{}) error) (id uint64)

Add channel handler to the reactor.

Returns id of added handler, that can be used later to remove it.

If limit is positive, at most this many items will be handled in each run through the main loop, otherwise it will process as many items as possible.

The handler function receives the value received from the channel.

func (*Reactor) AddChannelTime Uses

func (r *Reactor) AddChannelTime(ch <-chan time.Time, limit int, handler func(interface{}) error) (id uint64)

This function wraps AddChannel, using a channel of type time.Time instead of type interface{}.

func (*Reactor) AddSocket Uses

func (r *Reactor) AddSocket(soc *Socket, events State, handler func(State) error)

Add socket handler to the reactor.

You can have only one handler per socket. Adding a second one will remove the first.

The handler receives the socket state as an argument: POLLIN, POLLOUT, or both.

func (*Reactor) RemoveChannel Uses

func (r *Reactor) RemoveChannel(id uint64)

Remove a channel from the reactor.

Closed channels are removed automatically.

func (*Reactor) RemoveSocket Uses

func (r *Reactor) RemoveSocket(soc *Socket)

Remove a socket handler from the reactor.

func (*Reactor) Run Uses

func (r *Reactor) Run(interval time.Duration) (err error)

Run the reactor.

The interval determines the time-out on the polling of sockets. Interval must be positive if there are channels. If there are no channels, you can set interval to -1.

The run alternates between polling/handling sockets (using the interval as timeout), and reading/handling channels. The reading of channels is without time-out: if there is no activity on any channel, the run continues to poll sockets immediately.

The run exits when any handler returns an error, returning that same error.

func (*Reactor) SetVerbose Uses

func (r *Reactor) SetVerbose(verbose bool)

type Socket Uses

type Socket struct {
    // contains filtered or unexported fields
}

Socket functions starting with `Set` or `Get` are used for setting and getting socket options.

func NewSocket Uses

func NewSocket(t Type) (soc *Socket, err error)

Create 0MQ socket in the default context.

WARNING: The Socket is not thread safe. This means that you cannot access the same Socket from different goroutines without using something like a mutex.

For a description of socket types, see: http://api.zeromq.org/4-1:zmq-socket#toc3

func (*Socket) Bind Uses

func (soc *Socket) Bind(endpoint string) error

Accept incoming connections on a socket.

For a description of endpoint, see: http://api.zeromq.org/4-1:zmq-bind#toc2

func (*Socket) ClientAuthCurve Uses

func (client *Socket) ClientAuthCurve(server_public_key, client_public_key, client_secret_key string) error

Set CURVE client role.

func (*Socket) ClientAuthPlain Uses

func (client *Socket) ClientAuthPlain(username, password string) error

Set PLAIN client role.

func (*Socket) Close Uses

func (soc *Socket) Close() error

If not called explicitly, the socket will be closed on garbage collection

func (*Socket) Connect Uses

func (soc *Socket) Connect(endpoint string) error

Create outgoing connection from socket.

For a description of endpoint, see: http://api.zeromq.org/4-1:zmq-connect#toc2

func (*Socket) Context Uses

func (soc *Socket) Context() (*Context, error)

Return the context associated with a socket

func (*Socket) Disconnect Uses

func (soc *Socket) Disconnect(endpoint string) error

Disconnect a socket.

For a description of endpoint, see: http://api.zeromq.org/4-1:zmq-disconnect#toc2

func (*Socket) GetAffinity Uses

func (soc *Socket) GetAffinity() (uint64, error)

ZMQ_AFFINITY: Retrieve I/O thread affinity

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc3

func (*Socket) GetBacklog Uses

func (soc *Socket) GetBacklog() (int, error)

ZMQ_BACKLOG: Retrieve maximum length of the queue of outstanding connections

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc4

func (*Socket) GetConnectTimeout Uses

func (soc *Socket) GetConnectTimeout() (time.Duration, error)

ZMQ_CONNECT_TIMEOUT: Retrieve connect() timeout

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

See: http://api.zeromq.org/4-2:zmq-getsockopt#toc5

func (*Socket) GetCurvePublickeyRaw Uses

func (soc *Socket) GetCurvePublickeyRaw() (string, error)

ZMQ_CURVE_PUBLICKEY: Retrieve current CURVE public key

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc5

func (*Socket) GetCurvePublickeykeyZ85 Uses

func (soc *Socket) GetCurvePublickeykeyZ85() (string, error)

ZMQ_CURVE_PUBLICKEY: Retrieve current CURVE public key

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc5

func (*Socket) GetCurveSecretkeyRaw Uses

func (soc *Socket) GetCurveSecretkeyRaw() (string, error)

ZMQ_CURVE_SECRETKEY: Retrieve current CURVE secret key

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc6

func (*Socket) GetCurveSecretkeyZ85 Uses

func (soc *Socket) GetCurveSecretkeyZ85() (string, error)

ZMQ_CURVE_SECRETKEY: Retrieve current CURVE secret key

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc6

func (*Socket) GetCurveServerkeyRaw Uses

func (soc *Socket) GetCurveServerkeyRaw() (string, error)

ZMQ_CURVE_SERVERKEY: Retrieve current CURVE server key

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc7

func (*Socket) GetCurveServerkeyZ85 Uses

func (soc *Socket) GetCurveServerkeyZ85() (string, error)

ZMQ_CURVE_SERVERKEY: Retrieve current CURVE server key

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc7

func (*Socket) GetEvents Uses

func (soc *Socket) GetEvents() (State, error)

ZMQ_EVENTS: Retrieve socket event state

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc8

func (*Socket) GetFd Uses

func (soc *Socket) GetFd() (int, error)

ZMQ_FD: Retrieve file descriptor associated with the socket

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc9

func (*Socket) GetGssapiPlaintext Uses

func (soc *Socket) GetGssapiPlaintext() (bool, error)

ZMQ_GSSAPI_PLAINTEXT: Retrieve GSSAPI plaintext or encrypted status

Returns ErrorNotImplemented41 with ZeroMQ version < 4.1

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc10

func (*Socket) GetGssapiPrincipal Uses

func (soc *Socket) GetGssapiPrincipal() (string, error)

ZMQ_GSSAPI_PRINCIPAL: Retrieve the name of the GSSAPI principal

Returns ErrorNotImplemented41 with ZeroMQ version < 4.1

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc11

func (*Socket) GetGssapiServer Uses

func (soc *Socket) GetGssapiServer() (bool, error)

ZMQ_GSSAPI_SERVER: Retrieve current GSSAPI server role

Returns ErrorNotImplemented41 with ZeroMQ version < 4.1

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc12

func (*Socket) GetGssapiServicePrincipal Uses

func (soc *Socket) GetGssapiServicePrincipal() (string, error)

ZMQ_GSSAPI_SERVICE_PRINCIPAL: Retrieve the name of the GSSAPI service principal

Returns ErrorNotImplemented41 with ZeroMQ version < 4.1

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc13

func (*Socket) GetHandshakeIvl Uses

func (soc *Socket) GetHandshakeIvl() (time.Duration, error)

ZMQ_HANDSHAKE_IVL: Retrieve maximum handshake interval

Returns ErrorNotImplemented41 with ZeroMQ version < 4.1

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc14

func (*Socket) GetIdentity Uses

func (soc *Socket) GetIdentity() (string, error)

ZMQ_IDENTITY: Retrieve socket identity

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc15

func (*Socket) GetImmediate Uses

func (soc *Socket) GetImmediate() (bool, error)

ZMQ_IMMEDIATE: Retrieve attach-on-connect value

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc16

func (*Socket) GetInvertMatching Uses

func (soc *Socket) GetInvertMatching() (int, error)

ZMQ_INVERT_MATCHING: Retrieve inverted filtering status

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

See: http://api.zeromq.org/4-2:zmq-getsockopt#toc18

func (*Socket) GetIpv6 Uses

func (soc *Socket) GetIpv6() (bool, error)

ZMQ_IPV6: Retrieve IPv6 socket status

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc18

func (*Socket) GetLastEndpoint Uses

func (soc *Socket) GetLastEndpoint() (string, error)

ZMQ_LAST_ENDPOINT: Retrieve the last endpoint set

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc19

func (*Socket) GetLinger Uses

func (soc *Socket) GetLinger() (time.Duration, error)

ZMQ_LINGER: Retrieve linger period for socket shutdown

Returns time.Duration(-1) for infinite

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc20

func (*Socket) GetMaxmsgsize Uses

func (soc *Socket) GetMaxmsgsize() (int64, error)

ZMQ_MAXMSGSIZE: Maximum acceptable inbound message size

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc21

func (*Socket) GetMechanism Uses

func (soc *Socket) GetMechanism() (Mechanism, error)

ZMQ_MECHANISM: Retrieve current security mechanism

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc22

func (*Socket) GetMulticastHops Uses

func (soc *Socket) GetMulticastHops() (int, error)

ZMQ_MULTICAST_HOPS: Maximum network hops for multicast packets

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc23

func (*Socket) GetMulticastMaxtpdu Uses

func (soc *Socket) GetMulticastMaxtpdu() (int, error)

ZMQ_MULTICAST_MAXTPDU: Maximum transport data unit size for multicast packets

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

See: http://api.zeromq.org/4-2:zmq-getsockopt#toc26

func (*Socket) GetPlainPassword Uses

func (soc *Socket) GetPlainPassword() (string, error)

ZMQ_PLAIN_PASSWORD: Retrieve current password

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc24

func (*Socket) GetPlainServer Uses

func (soc *Socket) GetPlainServer() (int, error)

ZMQ_PLAIN_SERVER: Retrieve current PLAIN server role

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc25

func (*Socket) GetPlainUsername Uses

func (soc *Socket) GetPlainUsername() (string, error)

ZMQ_PLAIN_USERNAME: Retrieve current PLAIN username

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc26

func (*Socket) GetRate Uses

func (soc *Socket) GetRate() (int, error)

ZMQ_RATE: Retrieve multicast data rate

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc27

func (*Socket) GetRcvbuf Uses

func (soc *Socket) GetRcvbuf() (int, error)

ZMQ_RCVBUF: Retrieve kernel receive buffer size

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc28

func (*Socket) GetRcvhwm Uses

func (soc *Socket) GetRcvhwm() (int, error)

ZMQ_RCVHWM: Retrieve high water mark for inbound messages

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc29

func (*Socket) GetRcvmore Uses

func (soc *Socket) GetRcvmore() (bool, error)

ZMQ_RCVMORE: More message data parts to follow

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc30

func (*Socket) GetRcvtimeo Uses

func (soc *Socket) GetRcvtimeo() (time.Duration, error)

ZMQ_RCVTIMEO: Maximum time before a socket operation returns with EAGAIN

Returns time.Duration(-1) for infinite

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc31

func (*Socket) GetReconnectIvl Uses

func (soc *Socket) GetReconnectIvl() (time.Duration, error)

ZMQ_RECONNECT_IVL: Retrieve reconnection interval

Returns time.Duration(-1) for no reconnection

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc32

func (*Socket) GetReconnectIvlMax Uses

func (soc *Socket) GetReconnectIvlMax() (time.Duration, error)

ZMQ_RECONNECT_IVL_MAX: Retrieve maximum reconnection interval

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc33

func (*Socket) GetRecoveryIvl Uses

func (soc *Socket) GetRecoveryIvl() (time.Duration, error)

ZMQ_RECOVERY_IVL: Get multicast recovery interval

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc34

func (*Socket) GetSndbuf Uses

func (soc *Socket) GetSndbuf() (int, error)

ZMQ_SNDBUF: Retrieve kernel transmit buffer size

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc35

func (*Socket) GetSndhwm Uses

func (soc *Socket) GetSndhwm() (int, error)

ZMQ_SNDHWM: Retrieves high water mark for outbound messages

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc36

func (*Socket) GetSndtimeo Uses

func (soc *Socket) GetSndtimeo() (time.Duration, error)

ZMQ_SNDTIMEO: Maximum time before a socket operation returns with EAGAIN

Returns time.Duration(-1) for infinite

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc37

func (*Socket) GetSocksProxy Uses

func (soc *Socket) GetSocksProxy() (string, error)

ZMQ_SOCKS_PROXY: NOT DOCUMENTED

Returns ErrorNotImplemented41 with ZeroMQ version < 4.1

func (*Socket) GetTcpKeepalive Uses

func (soc *Socket) GetTcpKeepalive() (int, error)

ZMQ_TCP_KEEPALIVE: Override SO_KEEPALIVE socket option

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc38

func (*Socket) GetTcpKeepaliveCnt Uses

func (soc *Socket) GetTcpKeepaliveCnt() (int, error)

ZMQ_TCP_KEEPALIVE_CNT: Override TCP_KEEPCNT socket option

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc39

func (*Socket) GetTcpKeepaliveIdle Uses

func (soc *Socket) GetTcpKeepaliveIdle() (int, error)

ZMQ_TCP_KEEPALIVE_IDLE: Override TCP_KEEPCNT(or TCP_KEEPALIVE on some OS)

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc40

func (*Socket) GetTcpKeepaliveIntvl Uses

func (soc *Socket) GetTcpKeepaliveIntvl() (int, error)

ZMQ_TCP_KEEPALIVE_INTVL: Override TCP_KEEPINTVL socket option

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc41

func (*Socket) GetTcpMaxrt Uses

func (soc *Socket) GetTcpMaxrt() (time.Duration, error)

ZMQ_TCP_MAXRT: Retrieve Max TCP Retransmit Timeout

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

See: http://api.zeromq.org/4-2:zmq-getsockopt#toc44

func (*Socket) GetThreadSafe Uses

func (soc *Socket) GetThreadSafe() (bool, error)

ZMQ_THREAD_SAFE: Retrieve socket thread safety

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

See: http://api.zeromq.org/4-2:zmq-getsockopt#toc45

func (*Socket) GetTos Uses

func (soc *Socket) GetTos() (int, error)

ZMQ_TOS: Retrieve the Type-of-Service socket override status

Returns ErrorNotImplemented41 with ZeroMQ version < 4.1

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc42

func (*Socket) GetType Uses

func (soc *Socket) GetType() (Type, error)

ZMQ_TYPE: Retrieve socket type

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc43

func (*Socket) GetVmciBufferMaxSize Uses

func (soc *Socket) GetVmciBufferMaxSize() (uint64, error)

ZMQ_VMCI_BUFFER_MAX_SIZE: Retrieve max buffer size of the VMCI socket

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

See: http://api.zeromq.org/4-2:zmq-getsockopt#toc51

func (*Socket) GetVmciBufferMinSize Uses

func (soc *Socket) GetVmciBufferMinSize() (uint64, error)

ZMQ_VMCI_BUFFER_MIN_SIZE: Retrieve min buffer size of the VMCI socket

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

See: http://api.zeromq.org/4-2:zmq-getsockopt#toc50

func (*Socket) GetVmciBufferSize Uses

func (soc *Socket) GetVmciBufferSize() (uint64, error)

ZMQ_VMCI_BUFFER_SIZE: Retrieve buffer size of the VMCI socket

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

See: http://api.zeromq.org/4-2:zmq-getsockopt#toc49

func (*Socket) GetVmciConnectTimeout Uses

func (soc *Socket) GetVmciConnectTimeout() (time.Duration, error)

ZMQ_VMCI_CONNECT_TIMEOUT: Retrieve connection timeout of the VMCI socket

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

See: http://api.zeromq.org/4-2:zmq-getsockopt#toc52

func (*Socket) GetZapDomain Uses

func (soc *Socket) GetZapDomain() (string, error)

ZMQ_ZAP_DOMAIN: Retrieve RFC 27 authentication domain

See: http://api.zeromq.org/4-1:zmq-getsockopt#toc44

func (*Socket) Getusefd Uses

func (soc *Socket) Getusefd() (int, error)

ZMQ_USE_FD: Retrieve the pre-allocated socket file descriptor

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

See: http://api.zeromq.org/4-2:zmq-getsockopt#toc29

func (*Socket) Monitor Uses

func (soc *Socket) Monitor(addr string, events Event) error

Register a monitoring callback.

See: http://api.zeromq.org/4-1:zmq-socket-monitor#toc2

WARNING: Closing a context with a monitoring callback will lead to random crashes. This is a bug in the ZeroMQ library. The monitoring callback has the same context as the socket it was created for.

Example:

package main

import (
    zmq "github.com/pebbe/zmq4"
    "log"
    "time"
)

func rep_socket_monitor(addr string) {
    s, err := zmq.NewSocket(zmq.PAIR)
    if err != nil {
        log.Fatalln(err)
    }
    err = s.Connect(addr)
    if err != nil {
        log.Fatalln(err)
    }
    for {
        a, b, c, err := s.RecvEvent(0)
        if err != nil {
            log.Println(err)
            break
        }
        log.Println(a, b, c)
    }
    s.Close()
}

func main() {

    // REP socket
    rep, err := zmq.NewSocket(zmq.REP)
    if err != nil {
        log.Fatalln(err)
    }

    // REP socket monitor, all events
    err = rep.Monitor("inproc://monitor.rep", zmq.EVENT_ALL)
    if err != nil {
        log.Fatalln(err)
    }
    go rep_socket_monitor("inproc://monitor.rep")

    // Generate an event
    rep.Bind("tcp://*:5555")
    if err != nil {
        log.Fatalln(err)
    }

    // Allow some time for event detection
    time.Sleep(time.Second)

    rep.Close()
    zmq.Term()
}

func (*Socket) Recv Uses

func (soc *Socket) Recv(flags Flag) (string, error)

Receive a message part from a socket.

For a description of flags, see: http://api.zeromq.org/4-1:zmq-msg-recv#toc2

func (*Socket) RecvBytes Uses

func (soc *Socket) RecvBytes(flags Flag) ([]byte, error)

Receive a message part from a socket.

For a description of flags, see: http://api.zeromq.org/4-1:zmq-msg-recv#toc2

func (*Socket) RecvBytesWithMetadata Uses

func (soc *Socket) RecvBytesWithMetadata(flags Flag, properties ...string) (msg []byte, metadata map[string]string, err error)

Receive a message part with metadata.

This requires ZeroMQ version 4.1.0. Lower versions will return the message part without metadata.

The returned metadata map contains only those properties that exist on the message.

For a description of flags, see: http://api.zeromq.org/4-1:zmq-msg-recv#toc2

For a description of metadata, see: http://api.zeromq.org/4-1:zmq-msg-gets#toc3

func (*Socket) RecvEvent Uses

func (soc *Socket) RecvEvent(flags Flag) (event_type Event, addr string, value int, err error)

Receive a message part from a socket interpreted as an event.

For a description of flags, see: http://api.zeromq.org/4-1:zmq-msg-recv#toc2

For a description of event_type, see: http://api.zeromq.org/4-1:zmq-socket-monitor#toc3

For an example, see: func (*Socket) Monitor

func (*Socket) RecvMessage Uses

func (soc *Socket) RecvMessage(flags Flag) (msg []string, err error)

Receive parts as message from socket.

Returns last non-nil error code.

func (*Socket) RecvMessageBytes Uses

func (soc *Socket) RecvMessageBytes(flags Flag) (msg [][]byte, err error)

Receive parts as message from socket.

Returns last non-nil error code.

func (*Socket) RecvMessageBytesWithMetadata Uses

func (soc *Socket) RecvMessageBytesWithMetadata(flags Flag, properties ...string) (msg [][]byte, metadata map[string]string, err error)

Receive parts as message from socket, including metadata.

Metadata is picked from the first message part.

For details about metadata, see RecvBytesWithMetadata().

Returns last non-nil error code.

func (*Socket) RecvMessageWithMetadata Uses

func (soc *Socket) RecvMessageWithMetadata(flags Flag, properties ...string) (msg []string, metadata map[string]string, err error)

Receive parts as message from socket, including metadata.

Metadata is picked from the first message part.

For details about metadata, see RecvWithMetadata().

Returns last non-nil error code.

func (*Socket) RecvWithMetadata Uses

func (soc *Socket) RecvWithMetadata(flags Flag, properties ...string) (msg string, metadata map[string]string, err error)

Receive a message part with metadata.

This requires ZeroMQ version 4.1.0. Lower versions will return the message part without metadata.

The returned metadata map contains only those properties that exist on the message.

For a description of flags, see: http://api.zeromq.org/4-1:zmq-msg-recv#toc2

For a description of metadata, see: http://api.zeromq.org/4-1:zmq-msg-gets#toc3

func (*Socket) Send Uses

func (soc *Socket) Send(data string, flags Flag) (int, error)

Send a message part on a socket.

For a description of flags, see: http://api.zeromq.org/4-1:zmq-send#toc2

func (*Socket) SendBytes Uses

func (soc *Socket) SendBytes(data []byte, flags Flag) (int, error)

Send a message part on a socket.

For a description of flags, see: http://api.zeromq.org/4-1:zmq-send#toc2

func (*Socket) SendMessage Uses

func (soc *Socket) SendMessage(parts ...interface{}) (total int, err error)

Send multi-part message on socket.

Any `[]string' or `[][]byte' is split into separate `string's or `[]byte's

Any other part that isn't a `string' or `[]byte' is converted to `string' with `fmt.Sprintf("%v", part)'.

Returns total bytes sent.

func (*Socket) SendMessageDontwait Uses

func (soc *Socket) SendMessageDontwait(parts ...interface{}) (total int, err error)

Like SendMessage(), but adding the DONTWAIT flag.

func (*Socket) ServerAuthCurve Uses

func (server *Socket) ServerAuthCurve(domain, secret_key string) error

Set CURVE server role.

func (*Socket) ServerAuthNull Uses

func (server *Socket) ServerAuthNull(domain string) error

Set NULL server role.

func (*Socket) ServerAuthPlain Uses

func (server *Socket) ServerAuthPlain(domain string) error

Set PLAIN server role.

func (*Socket) SetAffinity Uses

func (soc *Socket) SetAffinity(value uint64) error

ZMQ_AFFINITY: Set I/O thread affinity

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc3

func (*Socket) SetBacklog Uses

func (soc *Socket) SetBacklog(value int) error

ZMQ_BACKLOG: Set maximum length of the queue of outstanding connections

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc4

func (*Socket) SetConflate Uses

func (soc *Socket) SetConflate(value bool) error

ZMQ_CONFLATE: Keep only last message

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc6

func (*Socket) SetConnectRid Uses

func (soc *Socket) SetConnectRid(value string) error

ZMQ_CONNECT_RID: Assign the next outbound connection id

Returns ErrorNotImplemented41 with ZeroMQ version < 4.1

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc5

func (*Socket) SetConnectTimeout Uses

func (soc *Socket) SetConnectTimeout(value time.Duration) error

ZMQ_CONNECT_TIMEOUT: Set connect() timeout

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

See: http://api.zeromq.org/4-2:zmq-setsockopt#toc7

func (*Socket) SetCurvePublickey Uses

func (soc *Socket) SetCurvePublickey(key string) error

ZMQ_CURVE_PUBLICKEY: Set CURVE public key

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc7

func (*Socket) SetCurveSecretkey Uses

func (soc *Socket) SetCurveSecretkey(key string) error

ZMQ_CURVE_SECRETKEY: Set CURVE secret key

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc8

func (*Socket) SetCurveServer Uses

func (soc *Socket) SetCurveServer(value int) error

ZMQ_CURVE_SERVER: Set CURVE server role

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc9

func (*Socket) SetCurveServerkey Uses

func (soc *Socket) SetCurveServerkey(key string) error

ZMQ_CURVE_SERVERKEY: Set CURVE server key

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc10

func (*Socket) SetGssapiPlaintext Uses

func (soc *Socket) SetGssapiPlaintext(value bool) error

ZMQ_GSSAPI_PLAINTEXT: Disable GSSAPI encryption

Returns ErrorNotImplemented41 with ZeroMQ version < 4.1

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc11

func (*Socket) SetGssapiPrincipal Uses

func (soc *Socket) SetGssapiPrincipal(value string) error

ZMQ_GSSAPI_PRINCIPAL: Set name of GSSAPI principal

Returns ErrorNotImplemented41 with ZeroMQ version < 4.1

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc12

func (*Socket) SetGssapiServer Uses

func (soc *Socket) SetGssapiServer(value bool) error

ZMQ_GSSAPI_SERVER: Set GSSAPI server role

Returns ErrorNotImplemented41 with ZeroMQ version < 4.1

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc13

func (*Socket) SetGssapiServicePrincipal Uses

func (soc *Socket) SetGssapiServicePrincipal(value string) error

ZMQ_GSSAPI_SERVICE_PRINCIPAL: Set name of GSSAPI service principal

Returns ErrorNotImplemented41 with ZeroMQ version < 4.1

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc14

func (*Socket) SetHandshakeIvl Uses

func (soc *Socket) SetHandshakeIvl(value time.Duration) error

ZMQ_HANDSHAKE_IVL: Set maximum handshake interval

Returns ErrorNotImplemented41 with ZeroMQ version < 4.1

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc15

func (*Socket) SetHeartbeatIvl Uses

func (soc *Socket) SetHeartbeatIvl(value time.Duration) error

ZMQ_HEARTBEAT_IVL: Set interval between sending ZMTP heartbeats

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

See: http://api.zeromq.org/4-2:zmq-setsockopt#toc17

func (*Socket) SetHeartbeatTimeout Uses

func (soc *Socket) SetHeartbeatTimeout(value time.Duration) error

ZMQ_HEARTBEAT_TIMEOUT: Set timeout for ZMTP heartbeats

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

See: http://api.zeromq.org/4-2:zmq-setsockopt#toc18

func (*Socket) SetHeartbeatTtl Uses

func (soc *Socket) SetHeartbeatTtl(value time.Duration) error

ZMQ_HEARTBEAT_TTL: Set the TTL value for ZMTP heartbeats

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

See: http://api.zeromq.org/4-2:zmq-setsockopt#toc19

func (*Socket) SetIdentity Uses

func (soc *Socket) SetIdentity(value string) error

ZMQ_IDENTITY: Set socket identity

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc16

func (*Socket) SetImmediate Uses

func (soc *Socket) SetImmediate(value bool) error

ZMQ_IMMEDIATE: Queue messages only to completed connections

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc17

func (*Socket) SetInvertMatching Uses

func (soc *Socket) SetInvertMatching(value int) error

ZMQ_INVERT_MATCHING: Invert message filtering

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

See: http://api.zeromq.org/4-2:zmq-setsockopt#toc22

func (*Socket) SetIpv6 Uses

func (soc *Socket) SetIpv6(value bool) error

ZMQ_IPV6: Enable IPv6 on socket

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc18

func (*Socket) SetLinger Uses

func (soc *Socket) SetLinger(value time.Duration) error

ZMQ_LINGER: Set linger period for socket shutdown

For infinite, use -1

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc19

func (*Socket) SetMaxmsgsize Uses

func (soc *Socket) SetMaxmsgsize(value int64) error

ZMQ_MAXMSGSIZE: Maximum acceptable inbound message size

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc20

func (*Socket) SetMulticastHops Uses

func (soc *Socket) SetMulticastHops(value int) error

ZMQ_MULTICAST_HOPS: Maximum network hops for multicast packets

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc21

func (*Socket) SetMulticastMaxtpdu Uses

func (soc *Socket) SetMulticastMaxtpdu(value int) error

ZMQ_MULTICAST_MAXTPDU: Maximum transport data unit size for multicast packets

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

See: http://api.zeromq.org/4-2:zmq-setsockopt#toc27

func (*Socket) SetPlainPassword Uses

func (soc *Socket) SetPlainPassword(password string) error

ZMQ_PLAIN_PASSWORD: Set PLAIN security password

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc22

func (*Socket) SetPlainServer Uses

func (soc *Socket) SetPlainServer(value int) error

ZMQ_PLAIN_SERVER: Set PLAIN server role

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc23

func (*Socket) SetPlainUsername Uses

func (soc *Socket) SetPlainUsername(username string) error

ZMQ_PLAIN_USERNAME: Set PLAIN security username

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc24

func (*Socket) SetProbeRouter Uses

func (soc *Socket) SetProbeRouter(value int) error

ZMQ_PROBE_ROUTER: bootstrap connections to ROUTER sockets

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc25

func (*Socket) SetRate Uses

func (soc *Socket) SetRate(value int) error

ZMQ_RATE: Set multicast data rate

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc26

func (*Socket) SetRcvbuf Uses

func (soc *Socket) SetRcvbuf(value int) error

ZMQ_RCVBUF: Set kernel receive buffer size

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc27

func (*Socket) SetRcvhwm Uses

func (soc *Socket) SetRcvhwm(value int) error

ZMQ_RCVHWM: Set high water mark for inbound messages

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc28

func (*Socket) SetRcvtimeo Uses

func (soc *Socket) SetRcvtimeo(value time.Duration) error

ZMQ_RCVTIMEO: Maximum time before a recv operation returns with EAGAIN

For infinite, use -1

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc29

func (*Socket) SetReconnectIvl Uses

func (soc *Socket) SetReconnectIvl(value time.Duration) error

ZMQ_RECONNECT_IVL: Set reconnection interval

For no reconnection, use -1

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc30

func (*Socket) SetReconnectIvlMax Uses

func (soc *Socket) SetReconnectIvlMax(value time.Duration) error

ZMQ_RECONNECT_IVL_MAX: Set maximum reconnection interval

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc31

func (*Socket) SetRecoveryIvl Uses

func (soc *Socket) SetRecoveryIvl(value time.Duration) error

ZMQ_RECOVERY_IVL: Set multicast recovery interval

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc32

func (*Socket) SetReqCorrelate Uses

func (soc *Socket) SetReqCorrelate(value int) error

ZMQ_REQ_CORRELATE: match replies with requests

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc33

func (*Socket) SetReqRelaxed Uses

func (soc *Socket) SetReqRelaxed(value int) error

ZMQ_REQ_RELAXED: relax strict alternation between request and reply

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc34

func (*Socket) SetRouterHandover Uses

func (soc *Socket) SetRouterHandover(value bool) error

ZMQ_ROUTER_HANDOVER: handle duplicate client identities on ROUTER sockets

Returns ErrorNotImplemented41 with ZeroMQ version < 4.1

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc35

func (*Socket) SetRouterMandatory Uses

func (soc *Socket) SetRouterMandatory(value int) error

ZMQ_ROUTER_MANDATORY: accept only routable messages on ROUTER sockets

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc36

func (*Socket) SetRouterRaw Uses

func (soc *Socket) SetRouterRaw(value int) error

ZMQ_ROUTER_RAW: switch ROUTER socket to raw mode

This option is deprecated since ZeroMQ version 4.1, please use ZMQ_STREAM sockets instead.

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc37

func (*Socket) SetSndbuf Uses

func (soc *Socket) SetSndbuf(value int) error

ZMQ_SNDBUF: Set kernel transmit buffer size

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc38

func (*Socket) SetSndhwm Uses

func (soc *Socket) SetSndhwm(value int) error

ZMQ_SNDHWM: Set high water mark for outbound messages

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc39

func (*Socket) SetSndtimeo Uses

func (soc *Socket) SetSndtimeo(value time.Duration) error

ZMQ_SNDTIMEO: Maximum time before a send operation returns with EAGAIN

For infinite, use -1

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc40

func (*Socket) SetSocksProxy Uses

func (soc *Socket) SetSocksProxy(value string) error

ZMQ_SOCKS_PROXY: NOT DOCUMENTED

Returns ErrorNotImplemented41 with ZeroMQ version < 4.1

func (*Socket) SetStreamNotify Uses

func (soc *Socket) SetStreamNotify(value int) error

ZMQ_STREAM_NOTIFY: send connect and disconnect notifications

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

See: http://api.zeromq.org/4-2:zmq-setsockopt#toc48

func (*Socket) SetSubscribe Uses

func (soc *Socket) SetSubscribe(filter string) error

ZMQ_SUBSCRIBE: Establish message filter

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc41

func (*Socket) SetTcpAcceptFilter Uses

func (soc *Socket) SetTcpAcceptFilter(filter string) error

ZMQ_TCP_ACCEPT_FILTER: Assign filters to allow new TCP connections

This option is deprecated since ZeroMQ version 4.1, please use authentication via the ZAP API and IP address whitelisting / blacklisting.

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc50

func (*Socket) SetTcpKeepalive Uses

func (soc *Socket) SetTcpKeepalive(value int) error

ZMQ_TCP_KEEPALIVE: Override SO_KEEPALIVE socket option

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc42

func (*Socket) SetTcpKeepaliveCnt Uses

func (soc *Socket) SetTcpKeepaliveCnt(value int) error

ZMQ_TCP_KEEPALIVE_CNT: Override TCP_KEEPCNT socket option

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc43

func (*Socket) SetTcpKeepaliveIdle Uses

func (soc *Socket) SetTcpKeepaliveIdle(value int) error

ZMQ_TCP_KEEPALIVE_IDLE: Override TCP_KEEPCNT(or TCP_KEEPALIVE on some OS)

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc44

func (*Socket) SetTcpKeepaliveIntvl Uses

func (soc *Socket) SetTcpKeepaliveIntvl(value int) error

ZMQ_TCP_KEEPALIVE_INTVL: Override TCP_KEEPINTVL socket option

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc45

func (*Socket) SetTcpMaxrt Uses

func (soc *Socket) SetTcpMaxrt(value time.Duration) error

ZMQ_TCP_MAXRT: Set TCP Maximum Retransmit Timeout

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

See: http://api.zeromq.org/4-2:zmq-setsockopt#toc54

func (*Socket) SetTos Uses

func (soc *Socket) SetTos(value int) error

ZMQ_TOS: Set the Type-of-Service on socket

Returns ErrorNotImplemented41 with ZeroMQ version < 4.1

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc46

func (*Socket) SetUnsubscribe Uses

func (soc *Socket) SetUnsubscribe(filter string) error

ZMQ_UNSUBSCRIBE: Remove message filter

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc47

func (*Socket) SetUseFd Uses

func (soc *Socket) SetUseFd(value int) error

ZMQ_USE_FD: Set the pre-allocated socket file descriptor

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

See: http://api.zeromq.org/4-2:zmq-setsockopt#toc31

func (*Socket) SetVmciBufferMaxSize Uses

func (soc *Socket) SetVmciBufferMaxSize(value uint64) error

ZMQ_VMCI_BUFFER_MAX_SIZE: Set max buffer size of the VMCI socket

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

See: http://api.zeromq.org/4-2:zmq-setsockopt#toc70

func (*Socket) SetVmciBufferMinSize Uses

func (soc *Socket) SetVmciBufferMinSize(value uint64) error

ZMQ_VMCI_BUFFER_MIN_SIZE: Set min buffer size of the VMCI socket

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

See: http://api.zeromq.org/4-2:zmq-setsockopt#toc69

func (*Socket) SetVmciBufferSize Uses

func (soc *Socket) SetVmciBufferSize(value uint64) error

ZMQ_VMCI_BUFFER_SIZE: Set buffer size of the VMCI socket

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

See: http://api.zeromq.org/4-2:zmq-setsockopt#toc68

func (*Socket) SetVmciConnectTimeout Uses

func (soc *Socket) SetVmciConnectTimeout(value time.Duration) error

ZMQ_VMCI_CONNECT_TIMEOUT: Set connection timeout of the VMCI socket

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

See: http://api.zeromq.org/4-2:zmq-setsockopt#toc71

func (*Socket) SetXpubManual Uses

func (soc *Socket) SetXpubManual(value int) error

ZMQ_XPUB_MANUAL: change the subscription handling to manual

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

See: http://api.zeromq.org/4-2:zmq-setsockopt#toc59

func (*Socket) SetXpubNodrop Uses

func (soc *Socket) SetXpubNodrop(value bool) error

ZMQ_XPUB_NODROP: do not silently drop messages if SENDHWM is reached

Returns ErrorNotImplemented41 with ZeroMQ version < 4.1

See: http://api.zeromq.org/4-2:zmq-setsockopt#toc60

func (*Socket) SetXpubVerbose Uses

func (soc *Socket) SetXpubVerbose(value int) error

ZMQ_XPUB_VERBOSE: provide all subscription messages on XPUB sockets

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc48

func (*Socket) SetXpubVerboser Uses

func (soc *Socket) SetXpubVerboser(value int) error

ZMQ_XPUB_VERBOSER: pass subscribe and unsubscribe messages on XPUB socket

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

See: http://api.zeromq.org/4-2:zmq-setsockopt#toc58

func (*Socket) SetXpubWelcomeMsg Uses

func (soc *Socket) SetXpubWelcomeMsg(value string) error

ZMQ_XPUB_WELCOME_MSG: set welcome message that will be received by subscriber when connecting

Returns ErrorNotImplemented42 with ZeroMQ version < 4.2

See: http://api.zeromq.org/4-2:zmq-setsockopt#toc61

func (*Socket) SetZapDomain Uses

func (soc *Socket) SetZapDomain(domain string) error

ZMQ_ZAP_DOMAIN: Set RFC 27 authentication domain

See: http://api.zeromq.org/4-1:zmq-setsockopt#toc49

func (Socket) String Uses

func (soc Socket) String() string

Socket as string.

func (*Socket) Unbind Uses

func (soc *Socket) Unbind(endpoint string) error

Stop accepting connections on a socket.

For a description of endpoint, see: http://api.zeromq.org/4-1:zmq-bind#toc2

type State Uses

type State int

Used by (soc *Socket)GetEvents()

func (State) String Uses

func (s State) String() string

Socket state as string.

type Type Uses

type Type int

Specifies the type of a socket, used by NewSocket()

func (Type) String Uses

func (t Type) String() string

Socket type as string.

Directories

PathSynopsis
draftA Go interface to ZeroMQ (zmq, 0mq) version 4.
examples
examples/bstarbstar - Binary Star reactor.
examples/cloneClone client API stack (multithreaded).
examples/flcliapiflcliapi - Freelance Pattern agent class.
examples/intfaceInterface class for Chapter 8.
examples/kvmsgkvmsg class - key-value message class for example applications
examples/kvsimplekvsimple - simple key-value message class for example applications.
examples/mdapiMajordomo Protocol Client and Worker API.
examples_security

Package zmq4 imports 10 packages (graph) and is imported by 337 packages. Updated 2019-07-24. Refresh now. Tools for package owners.