zmq3

package
Version: v0.0.0-...-fd4faf2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2016 License: BSD-2-Clause, MIT Imports: 8 Imported by: 0

README

A Go interface to ZeroMQ version 3.

For ZeroMQ version 4, see: http://github.com/pebbe/zmq4

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

Including all examples of ØMQ - The Guide.

Keywords: zmq, zeromq, 0mq, networks, distributed computing, message passing, fanout, pubsub, pipeline, request-reply

Install

go get github.com/pebbe/zmq3

Docs

Documentation

Overview

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

For ZeroMQ version 4, see: http://github.com/pebbe/zmq4

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

http://www.zeromq.org/

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.

Example (Test_connect_delay)
package main

import (
	"fmt"
)

func main() {

	fmt.Println("Done")
}
Output:

Done
Example (Test_connect_resolve)
package main

import (
	"fmt"
	"runtime"

	zmq "github.com/pebbe/zmq3"
)

func main() {

	/*
		copied from zmq4
	*/

	sock, err := zmq.NewSocket(zmq.PUB)
	if checkErr(err) {
		return
	}

	err = sock.Connect("tcp://localhost:1234")
	checkErr(err)

	err = sock.Connect("tcp://localhost:invalid")
	fmt.Println(err)

	err = sock.Connect("tcp://in val id:1234")
	fmt.Println(err)

	err = sock.Connect("invalid://localhost:1234")
	fmt.Println(err)

	err = sock.Close()
	checkErr(err)

	fmt.Println("Done")
}

func checkErr(err error) bool {
	if err != nil {
		_, filename, lineno, ok := runtime.Caller(1)
		if ok {
			fmt.Printf("%v:%v: %v\n", filename, lineno, err)
		} else {
			fmt.Println(err)
		}
		return true
	}
	return false
}
Output:

invalid argument
invalid argument
protocol not supported
Done
Example (Test_disconnect_inproc)
package main

import (
	"fmt"
)

func main() {

	fmt.Println("Done")
}
Output:

Done
Example (Test_hwm)
package main

import (
	"fmt"
)

func main() {

	fmt.Println("Done")
}
Output:

Done
Example (Test_invalid_rep)
package main

import (
	"fmt"
)

func main() {

	fmt.Println("Done")
}
Output:

Done
Example (Test_last_endpoint)
package main

import (
	"fmt"
)

func main() {

	fmt.Println("Done")
}
Output:

Done
Example (Test_monitor)
package main

import (
	"fmt"
)

func main() {

	fmt.Println("Done")
}
Output:

Done
Example (Test_msg_flags)
package main

import (
	"fmt"
)

func main() {

	fmt.Println("Done")
}
Output:

Done
Example (Test_pair_inproc)
package main

import (
	"fmt"
)

func main() {

	fmt.Println("Done")
}
Output:

Done
Example (Test_pair_ipc)
package main

import (
	"fmt"
)

func main() {

	fmt.Println("Done")
}
Output:

Done
Example (Test_pair_tcp)
package main

import (
	"fmt"
)

func main() {

	fmt.Println("Done")
}
Output:

Done
Example (Test_reqrep_device)
package main

import (
	"fmt"
)

func main() {

	fmt.Println("Done")
}
Output:

Done
Example (Test_reqrep_inproc)
package main

import (
	"fmt"
)

func main() {

	fmt.Println("Done")
}
Output:

Done
Example (Test_reqrep_ipc)
package main

import (
	"fmt"
)

func main() {

	fmt.Println("Done")
}
Output:

Done
Example (Test_reqrep_tcp)
package main

import (
	"fmt"
)

func main() {

	fmt.Println("Done")
}
Output:

Done
Example (Test_router_mandatory)
package main

import (
	"fmt"
)

func main() {

	fmt.Println("Done")
}
Output:

Done
Example (Test_shutdown_stress)
package main

import (
	"fmt"
)

func main() {

	fmt.Println("Done")
}
Output:

Done
Example (Test_sub_forward)
package main

import (
	"fmt"
)

func main() {

	fmt.Println("Done")
}
Output:

Done
Example (Test_term_endpoint)
package main

import (
	"fmt"
)

func main() {

	fmt.Println("Done")
}
Output:

Done
Example (Test_timeo)
package main

import (
	"fmt"
)

func main() {

	fmt.Println("Done")
}
Output:

Done

Index

Examples

Constants

View Source
const (
	// Constants for NewSocket()
	// See: http://api.zeromq.org/3-2: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)
)
View Source
const (
	// Flags for (*Socket)Send(), (*Socket)Recv()
	// For Send, see: http://api.zeromq.org/3-2:zmq-send#toc2
	// For Recv, see: http://api.zeromq.org/3-2:zmq-msg-recv#toc2
	DONTWAIT = Flag(C.ZMQ_DONTWAIT)
	SNDMORE  = Flag(C.ZMQ_SNDMORE)
)
View Source
const (
	// Flags for (*Socket)Monitor() and (*Socket)RecvEvent()
	// See: http://api.zeromq.org/3-2:zmq-socket-monitor#toc2
	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)
)
View Source
const (
	// Flags for (*Socket)GetEvents()
	// See: http://api.zeromq.org/3-2:zmq-getsockopt#toc24
	POLLIN  = State(C.ZMQ_POLLIN)
	POLLOUT = State(C.ZMQ_POLLOUT)
)

Variables

This section is empty.

Functions

func Error

func Error(e int) string

Get 0MQ error message string.

func GetIoThreads

func GetIoThreads() (int, error)

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

func GetMaxSockets

func GetMaxSockets() (int, error)

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

func Proxy

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

Start built-in ØMQ proxy

See: http://api.zeromq.org/3-2:zmq-proxy

func SetIoThreads

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 SetMaxSockets

func SetMaxSockets(n int) error

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

Default value 1024

func Term

func Term() error

Terminates the default context.

For linger behavior, see: http://api.zeromq.org/3-2:zmq-ctx-destroy

func Version

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

Report 0MQ library version.

Types

type Context

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

A context that is not the default context.

func NewContext

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

Create a new context.

func (*Context) GetIoThreads

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

Returns the size of the 0MQ thread pool.

func (*Context) GetMaxSockets

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

Returns the maximum number of sockets allowed.

func (*Context) NewSocket

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/3-2:zmq-socket#toc3

func (*Context) SetIoThreads

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) SetMaxSockets

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

Sets the maximum number of sockets allowed.

Default value 1024

func (*Context) Term

func (ctx *Context) Term() error

Terminates the context.

For linger behavior, see: http://api.zeromq.org/3-2:zmq-ctx-destroy

type Event

type Event int

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

func (Event) String

func (e Event) String() string

Socket event as string.

type Flag

type Flag int

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

func (Flag) String

func (f Flag) String() string

Socket flag as string.

type Polled

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

Return type for (*Poller)Poll

type Poller

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

func NewPoller

func NewPoller() *Poller

Create a new Poller

func (*Poller) Add

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

Add items to the poller

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

func (*Poller) Poll

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

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) String

func (p *Poller) String() string

Poller as string.

type Reactor

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

func NewReactor

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

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

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

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

func (r *Reactor) RemoveChannel(id uint64)

Remove a channel from the reactor.

Closed channels are removed automaticly.

func (*Reactor) RemoveSocket

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

Remove a socket handler from the reactor.

func (*Reactor) Run

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

func (r *Reactor) SetVerbose(verbose bool)

type Socket

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

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/3-2:zmq-socket#toc3

func (*Socket) Bind

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

Accept incoming connections on a socket.

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

func (*Socket) Close

func (soc *Socket) Close() error

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

func (*Socket) Connect

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

Create outgoing connection from socket.

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

func (*Socket) Disconnect

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

Disconnect a socket.

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

func (*Socket) GetAffinity

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

ZMQ_AFFINITY: Retrieve I/O thread affinity

See: http://api.zeromq.org/3-2:zmq-getsockopt#toc7

func (*Socket) GetBacklog

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

ZMQ_BACKLOG: Retrieve maximum length of the queue of outstanding connections

See: http://api.zeromq.org/3-2:zmq-getsockopt#toc16

func (*Socket) GetDelayAttachOnConnect

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

ZMQ_DELAY_ATTACH_ON_CONNECT: Retrieve attach-on-connect value

See: http://api.zeromq.org/3-2:zmq-getsockopt#toc22

func (*Socket) GetEvents

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

ZMQ_EVENTS: Retrieve socket event state

See: http://api.zeromq.org/3-2:zmq-getsockopt#toc24

func (*Socket) GetFd

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

ZMQ_FD: Retrieve file descriptor associated with the socket

See: http://api.zeromq.org/3-2:zmq-getsockopt#toc23

func (*Socket) GetIdentity

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

ZMQ_IDENTITY: Get socket identity

See: http://api.zeromq.org/3-2:zmq-getsockopt#toc8

func (*Socket) GetIpv4only

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

ZMQ_IPV4ONLY: Retrieve IPv4-only socket override status

See: http://api.zeromq.org/3-2:zmq-getsockopt#toc21

func (*Socket) GetLastEndpoint

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

ZMQ_LAST_ENDPOINT: Retrieve the last endpoint set

See: http://api.zeromq.org/3-2:zmq-getsockopt#toc25

func (*Socket) GetLinger

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/3-2:zmq-getsockopt#toc13

func (*Socket) GetMaxmsgsize

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

ZMQ_MAXMSGSIZE: Maximum acceptable inbound message size

See: http://api.zeromq.org/3-2:zmq-getsockopt#toc17

func (*Socket) GetMulticastHops

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

ZMQ_MULTICAST_HOPS: Maximum network hops for multicast packets

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

func (*Socket) GetRate

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

ZMQ_RATE: Retrieve multicast data rate

See: http://api.zeromq.org/3-2:zmq-getsockopt#toc9

func (*Socket) GetRcvbuf

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

ZMQ_RCVBUF: Retrieve kernel receive buffer size

See: http://api.zeromq.org/3-2:zmq-getsockopt#toc12

func (*Socket) GetRcvhwm

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

ZMQ_RCVHWM: Retrieve high water mark for inbound messages

See: http://api.zeromq.org/3-2:zmq-getsockopt#toc6

func (*Socket) GetRcvmore

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

ZMQ_RCVMORE: More message data parts to follow

See: http://api.zeromq.org/3-2:zmq-getsockopt#toc4

func (*Socket) GetRcvtimeo

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/3-2:zmq-getsockopt#toc19

func (*Socket) GetReconnectIvl

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/3-2:zmq-getsockopt#toc14

func (*Socket) GetReconnectIvlMax

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

ZMQ_RECONNECT_IVL_MAX: Retrieve maximum reconnection interval

See: http://api.zeromq.org/3-2:zmq-getsockopt#toc15

func (*Socket) GetRecoveryIvl

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

ZMQ_RECOVERY_IVL: Get multicast recovery interval

See: http://api.zeromq.org/3-2:zmq-getsockopt#toc10

func (*Socket) GetSndbuf

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

ZMQ_SNDBUF: Retrieve kernel transmit buffer size

See: http://api.zeromq.org/3-2:zmq-getsockopt#toc11

func (*Socket) GetSndhwm

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

ZMQ_SNDHWM: Retrieves high water mark for outbound messages

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

func (*Socket) GetSndtimeo

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/3-2:zmq-getsockopt#toc20

func (*Socket) GetTcpKeepalive

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

ZMQ_TCP_KEEPALIVE: Override SO_KEEPALIVE socket option

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

func (*Socket) GetTcpKeepaliveCnt

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

ZMQ_TCP_KEEPALIVE_CNT: Override TCP_KEEPCNT socket option

See: http://api.zeromq.org/3-2:zmq-getsockopt#toc28

func (*Socket) GetTcpKeepaliveIdle

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

ZMQ_TCP_KEEPALIVE_IDLE: Override TCP_KEEPCNT(or TCP_KEEPALIVE on some OS)

See: http://api.zeromq.org/3-2:zmq-getsockopt#toc27

func (*Socket) GetTcpKeepaliveIntvl

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

ZMQ_TCP_KEEPALIVE_INTVL: Override TCP_KEEPINTVL socket option

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

func (*Socket) GetType

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

ZMQ_TYPE: Retrieve socket type

See: http://api.zeromq.org/3-2:zmq-getsockopt#toc3

func (*Socket) Monitor

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

Register a monitoring callback.

See: http://api.zeromq.org/3-2:zmq-socket-monitor#toc2

Example:

package main

import (
    zmq "github.com/pebbe/zmq3"
    "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

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/3-2:zmq-msg-recv#toc2

func (*Socket) RecvBytes

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/3-2:zmq-msg-recv#toc2

func (*Socket) RecvEvent

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/3-2:zmq-msg-recv#toc2

For a description of event_type, see: http://api.zeromq.org/3-2:zmq-socket-monitor#toc2

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

func (*Socket) RecvMessage

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

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

Receive parts as message from socket.

Returns last non-nil error code.

func (*Socket) Send

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/3-2:zmq-send#toc2

func (*Socket) SendBytes

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/3-2:zmq-send#toc2

func (*Socket) SendMessage

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) SetAffinity

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

ZMQ_AFFINITY: Set I/O thread affinity

See: http://api.zeromq.org/3-2:zmq-setsockopt#toc5

func (*Socket) SetBacklog

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

ZMQ_BACKLOG: Set maximum length of the queue of outstanding connections

See: http://api.zeromq.org/3-2:zmq-setsockopt#toc16

func (*Socket) SetDelayAttachOnConnect

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

ZMQ_DELAY_ATTACH_ON_CONNECT: Accept messages only when connections are made

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

func (*Socket) SetIdentity

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

ZMQ_IDENTITY: Set socket identity

See: http://api.zeromq.org/3-2:zmq-setsockopt#toc8

func (*Socket) SetIpv4only

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

ZMQ_IPV4ONLY: Use IPv4-only sockets

See: http://api.zeromq.org/3-2:zmq-setsockopt#toc21

func (*Socket) SetLinger

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

ZMQ_LINGER: Set linger period for socket shutdown

Use -1 for infinite

See: http://api.zeromq.org/3-2:zmq-setsockopt#toc13

func (*Socket) SetMaxmsgsize

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

ZMQ_MAXMSGSIZE: Maximum acceptable inbound message size

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

func (*Socket) SetMulticastHops

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

ZMQ_MULTICAST_HOPS: Maximum network hops for multicast packets

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

func (*Socket) SetRate

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

ZMQ_RATE: Set multicast data rate

See: http://api.zeromq.org/3-2:zmq-setsockopt#toc9

func (*Socket) SetRcvbuf

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

ZMQ_RCVBUF: Set kernel receive buffer size

See: http://api.zeromq.org/3-2:zmq-setsockopt#toc12

func (*Socket) SetRcvhwm

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

ZMQ_RCVHWM: Set high water mark for inbound messages

See: http://api.zeromq.org/3-2:zmq-setsockopt#toc4

func (*Socket) SetRcvtimeo

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

ZMQ_RCVTIMEO: Maximum time before a recv operation returns with EAGAIN

Use -1 for infinite

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

func (*Socket) SetReconnectIvl

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

ZMQ_RECONNECT_IVL: Set reconnection interval

Use -1 for no reconnection

See: http://api.zeromq.org/3-2:zmq-setsockopt#toc14

func (*Socket) SetReconnectIvlMax

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

ZMQ_RECONNECT_IVL_MAX: Set maximum reconnection interval

See: http://api.zeromq.org/3-2:zmq-setsockopt#toc15

func (*Socket) SetRecoveryIvl

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

ZMQ_RECOVERY_IVL: Set multicast recovery interval

See: http://api.zeromq.org/3-2:zmq-setsockopt#toc10

func (*Socket) SetRouterMandatory

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

ZMQ_ROUTER_MANDATORY: accept only routable messages on ROUTER sockets

See: http://api.zeromq.org/3-2:zmq-setsockopt#toc23

func (*Socket) SetSndbuf

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

ZMQ_SNDBUF: Set kernel transmit buffer size

See: http://api.zeromq.org/3-2:zmq-setsockopt#toc11

func (*Socket) SetSndhwm

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

ZMQ_SNDHWM: Set high water mark for outbound messages

See: http://api.zeromq.org/3-2:zmq-setsockopt#toc3

func (*Socket) SetSndtimeo

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

ZMQ_SNDTIMEO: Maximum time before a send operation returns with EAGAIN

Use -1 for infinite

See: http://api.zeromq.org/3-2:zmq-setsockopt#toc20

func (*Socket) SetSubscribe

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

ZMQ_SUBSCRIBE: Establish message filter

See: http://api.zeromq.org/3-2:zmq-setsockopt#toc6

func (*Socket) SetTcpAcceptFilter

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

ZMQ_TCP_ACCEPT_FILTER: Assign filters to allow new TCP connections

See: http://api.zeromq.org/3-2:zmq-setsockopt#toc29

func (*Socket) SetTcpKeepalive

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

ZMQ_TCP_KEEPALIVE: Override SO_KEEPALIVE socket option

See: http://api.zeromq.org/3-2:zmq-setsockopt#toc25

func (*Socket) SetTcpKeepaliveCnt

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

ZMQ_TCP_KEEPALIVE_CNT: Override TCP_KEEPCNT socket option

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

func (*Socket) SetTcpKeepaliveIdle

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/3-2:zmq-setsockopt#toc26

func (*Socket) SetTcpKeepaliveIntvl

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

ZMQ_TCP_KEEPALIVE_INTVL: Override TCP_KEEPINTVL socket option

See: http://api.zeromq.org/3-2:zmq-setsockopt#toc28

func (*Socket) SetUnsubscribe

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

ZMQ_UNSUBSCRIBE: Remove message filter

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

func (*Socket) SetXpubVerbose

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

ZMQ_XPUB_VERBOSE: provide all subscription messages on XPUB sockets

See: http://api.zeromq.org/3-2:zmq-setsockopt#toc24

func (Socket) String

func (soc Socket) String() string

Socket as string.

func (*Socket) Unbind

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

Stop accepting connections on a socket.

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

type State

type State int

Used by (soc *Socket)GetEvents()

func (State) String

func (s State) String() string

Socket state as string.

type Type

type Type int

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

func (Type) String

func (t Type) String() string

Socket type as string.

Directories

Path Synopsis
bstar
bstar - Binary Star reactor.
bstar - Binary Star reactor.
clone
Clone client API stack (multithreaded).
Clone client API stack (multithreaded).
flcliapi
flcliapi - Freelance Pattern agent class.
flcliapi - Freelance Pattern agent class.
intface
Interface class for Chapter 8.
Interface class for Chapter 8.
kvmsg
kvmsg class - key-value message class for example applications
kvmsg class - key-value message class for example applications
kvsimple
kvsimple - simple key-value message class for example applications.
kvsimple - simple key-value message class for example applications.
mdapi
Majordomo Protocol Client and Worker API.
Majordomo Protocol Client and Worker API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL