PageRenderTime 50ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/README.md

http://github.com/alecthomas/gozmq
Markdown | 1024 lines | 711 code | 313 blank | 0 comment | 0 complexity | 82597b58500a8b84e1c4ad8a646efda7 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. # _NOTE:_ These gozmq bindings are in maintenance mode. Only critical bugs will be fixed. Henceforth I would suggest using [@pebbe's](https://github.com/pebbe) actively maintained bindings for [zmq2](https://github.com/pebbe/zmq2), [zmq3](https://github.com/pebbe/zmq3) and [zmq4](https://github.com/pebbe/zmq4).
  2. ## Go (golang) Bindings for 0mq (zmq, zeromq)
  3. [![Build Status](https://travis-ci.org/alecthomas/gozmq.png)](https://travis-ci.org/alecthomas/gozmq)
  4. This package implements [Go](http://golang.org) (golang) bindings for
  5. the [0mq](http://zeromq.org) C API.
  6. GoZMQ [does not](#zero-copy) support zero-copy.
  7. A full list of examples is included in the [zguide](https://github.com/imatix/zguide/tree/master/examples/Go).
  8. Note that this is *not* the same as [this
  9. implementation](http://github.com/boggle/gozero) or [this
  10. implementation](http://code.google.com/p/gozmq/).
  11. ## Upgrading
  12. GoZMQ has made some public changes that will break old code. Fortunately, we've also written a tool based on `go fix` that will upgrade your code for you! Here's how to run it over your source (after making a backup of course):
  13. go get github.com/alecthomas/gozmq/gozmqfix
  14. cd $YOUR_SOURCE_DIR
  15. gozmqfix .
  16. ## Installing
  17. GoZMQ currently supports ZMQ 2.1.x, 2.2.x, 3.x and 4.x. Following are instructions on how to compile against these versions.
  18. For ZeroMQ 2.2.x install with:
  19. go get github.com/alecthomas/gozmq
  20. For 2.1.x install with:
  21. go get -tags zmq_2_1 github.com/alecthomas/gozmq
  22. For 3.x install with:
  23. go get -tags zmq_3_x github.com/alecthomas/gozmq
  24. For 4.x install with:
  25. go get -tags zmq_4_x github.com/alecthomas/gozmq
  26. ### Troubleshooting
  27. #### Go can't find ZMQ
  28. If the go tool can't find zmq and you know it is installed, you may need to override the C compiler/linker flags.
  29. eg. If you installed zmq into `/opt/zmq` you might try:
  30. CGO_CFLAGS=-I/opt/zmq/include CGO_LDFLAGS=-L/opt/zmq/lib \
  31. go get github.com/alecthomas/gozmq
  32. #### Mismatch in version of ZMQ
  33. If you get errors like this with 'go get' or 'go build':
  34. 1: error: 'ZMQ_FOO' undeclared (first use in this function)
  35. There are two possibilities:
  36. 1. Your version of zmq is *very* old. In this case you will need to download and build zmq yourself.
  37. 2. You are building gozmq against the wrong version of zmq. See the [installation](#installation) instructions for details on how to target the correct version.
  38. ## Differences from the C API
  39. The API implemented by this package does not attempt to expose
  40. `zmq_msg_t` at all. Instead, `Recv()` and `Send()` both operate on byte
  41. slices, allocating and freeing the memory automatically. Currently this
  42. requires copying to/from C malloced memory, but a future implementation
  43. may be able to avoid this to a certain extent.
  44. All major features are supported: contexts, sockets, devices, and polls.
  45. ## Example
  46. Here are direct translations of some of the examples from [this blog
  47. post](http://nichol.as/zeromq-an-introduction).
  48. A simple echo server:
  49. ```go
  50. package main
  51. import zmq "github.com/alecthomas/gozmq"
  52. func main() {
  53. context, _ := zmq.NewContext()
  54. socket, _ := context.NewSocket(zmq.REP)
  55. socket.Bind("tcp://127.0.0.1:5000")
  56. socket.Bind("tcp://127.0.0.1:6000")
  57. for {
  58. msg, _ := socket.Recv(0)
  59. println("Got", string(msg))
  60. socket.Send(msg, 0)
  61. }
  62. }
  63. ```
  64. A simple client for the above server:
  65. ```go
  66. package main
  67. import "fmt"
  68. import zmq "github.com/alecthomas/gozmq"
  69. func main() {
  70. context, _ := zmq.NewContext()
  71. socket, _ := context.NewSocket(zmq.REQ)
  72. socket.Connect("tcp://127.0.0.1:5000")
  73. socket.Connect("tcp://127.0.0.1:6000")
  74. for i := 0; i < 10; i++ {
  75. msg := fmt.Sprintf("msg %d", i)
  76. socket.Send([]byte(msg), 0)
  77. println("Sending", msg)
  78. socket.Recv(0)
  79. }
  80. }
  81. ```
  82. ## Caveats
  83. ### Zero-copy
  84. GoZMQ does not support zero-copy.
  85. GoZMQ does not attempt to expose `zmq_msg_t` at all. Instead, `Recv()` and `Send()`
  86. both operate on byte slices, allocating and freeing the memory automatically.
  87. Currently this requires copying to/from C malloced memory, but a future
  88. implementation may be able to avoid this to a certain extent.
  89. ### Memory management
  90. It's not entirely clear from the 0mq documentation how memory for
  91. `zmq_msg_t` and packet data is managed once 0mq takes ownership. After
  92. digging into the source a little, this package operates under the
  93. following (educated) assumptions:
  94. - References to `zmq_msg_t` structures are not held by the C API
  95. beyond the duration of any function call.
  96. - Packet data is reference counted internally by the C API. The count
  97. is incremented when a packet is queued for delivery to a destination
  98. (the inference being that for delivery to N destinations, the
  99. reference count will be incremented N times) and decremented once
  100. the packet has either been delivered or errored.
  101. ## Usage
  102. ```go
  103. const (
  104. // NewSocket types
  105. PAIR = SocketType(C.ZMQ_PAIR)
  106. PUB = SocketType(C.ZMQ_PUB)
  107. SUB = SocketType(C.ZMQ_SUB)
  108. REQ = SocketType(C.ZMQ_REQ)
  109. REP = SocketType(C.ZMQ_REP)
  110. DEALER = SocketType(C.ZMQ_DEALER)
  111. ROUTER = SocketType(C.ZMQ_ROUTER)
  112. PULL = SocketType(C.ZMQ_PULL)
  113. PUSH = SocketType(C.ZMQ_PUSH)
  114. XPUB = SocketType(C.ZMQ_XPUB)
  115. XSUB = SocketType(C.ZMQ_XSUB)
  116. // Deprecated aliases
  117. XREQ = DEALER
  118. XREP = ROUTER
  119. UPSTREAM = PULL
  120. DOWNSTREAM = PUSH
  121. // NewSocket options
  122. AFFINITY = UInt64SocketOption(C.ZMQ_AFFINITY)
  123. IDENTITY = StringSocketOption(C.ZMQ_IDENTITY)
  124. SUBSCRIBE = StringSocketOption(C.ZMQ_SUBSCRIBE)
  125. UNSUBSCRIBE = StringSocketOption(C.ZMQ_UNSUBSCRIBE)
  126. RATE = Int64SocketOption(C.ZMQ_RATE)
  127. RECOVERY_IVL = Int64SocketOption(C.ZMQ_RECOVERY_IVL)
  128. SNDBUF = UInt64SocketOption(C.ZMQ_SNDBUF)
  129. RCVBUF = UInt64SocketOption(C.ZMQ_RCVBUF)
  130. FD = Int64SocketOption(C.ZMQ_FD)
  131. EVENTS = UInt64SocketOption(C.ZMQ_EVENTS)
  132. TYPE = UInt64SocketOption(C.ZMQ_TYPE)
  133. LINGER = IntSocketOption(C.ZMQ_LINGER)
  134. RECONNECT_IVL = IntSocketOption(C.ZMQ_RECONNECT_IVL)
  135. RECONNECT_IVL_MAX = IntSocketOption(C.ZMQ_RECONNECT_IVL_MAX)
  136. BACKLOG = IntSocketOption(C.ZMQ_BACKLOG)
  137. // Send/recv options
  138. SNDMORE = SendRecvOption(C.ZMQ_SNDMORE)
  139. )
  140. ```
  141. ```go
  142. const (
  143. POLLIN = PollEvents(C.ZMQ_POLLIN)
  144. POLLOUT = PollEvents(C.ZMQ_POLLOUT)
  145. POLLERR = PollEvents(C.ZMQ_POLLERR)
  146. )
  147. ```
  148. ```go
  149. const (
  150. STREAMER = DeviceType(C.ZMQ_STREAMER)
  151. FORWARDER = DeviceType(C.ZMQ_FORWARDER)
  152. QUEUE = DeviceType(C.ZMQ_QUEUE)
  153. )
  154. ```
  155. ```go
  156. const (
  157. RCVTIMEO = IntSocketOption(C.ZMQ_RCVTIMEO)
  158. SNDTIMEO = IntSocketOption(C.ZMQ_SNDTIMEO)
  159. )
  160. ```
  161. ```go
  162. const (
  163. RCVMORE = UInt64SocketOption(C.ZMQ_RCVMORE)
  164. RECOVERY_IVL_MSEC = Int64SocketOption(C.ZMQ_RECOVERY_IVL_MSEC)
  165. SWAP = Int64SocketOption(C.ZMQ_SWAP)
  166. MCAST_LOOP = Int64SocketOption(C.ZMQ_MCAST_LOOP)
  167. HWM = UInt64SocketOption(C.ZMQ_HWM)
  168. NOBLOCK = SendRecvOption(C.ZMQ_NOBLOCK)
  169. // Forwards-compatible aliases:
  170. DONTWAIT = NOBLOCK
  171. )
  172. ```
  173. ```go
  174. const (
  175. RCVMORE = IntSocketOption(C.ZMQ_RCVMORE)
  176. SNDHWM = IntSocketOption(C.ZMQ_SNDHWM)
  177. RCVHWM = IntSocketOption(C.ZMQ_RCVHWM)
  178. // TODO Not documented in the man page...
  179. //LAST_ENDPOINT = UInt64SocketOption(C.ZMQ_LAST_ENDPOINT)
  180. FAIL_UNROUTABLE = BoolSocketOption(C.ZMQ_FAIL_UNROUTABLE)
  181. TCP_KEEPALIVE = IntSocketOption(C.ZMQ_TCP_KEEPALIVE)
  182. TCP_KEEPALIVE_CNT = IntSocketOption(C.ZMQ_TCP_KEEPALIVE_CNT)
  183. TCP_KEEPALIVE_IDLE = IntSocketOption(C.ZMQ_TCP_KEEPALIVE_IDLE)
  184. TCP_KEEPALIVE_INTVL = IntSocketOption(C.ZMQ_TCP_KEEPALIVE_INTVL)
  185. TCP_ACCEPT_FILTER = StringSocketOption(C.ZMQ_TCP_ACCEPT_FILTER)
  186. // Message options
  187. MORE = MessageOption(C.ZMQ_MORE)
  188. // Send/recv options
  189. DONTWAIT = SendRecvOption(C.ZMQ_DONTWAIT)
  190. // Deprecated aliases
  191. NOBLOCK = DONTWAIT
  192. )
  193. ```
  194. ```go
  195. var (
  196. // Additional ZMQ errors
  197. ENOTSOCK error = zmqErrno(C.ENOTSOCK)
  198. EFSM error = zmqErrno(C.EFSM)
  199. EINVAL error = zmqErrno(C.EINVAL)
  200. ENOCOMPATPROTO error = zmqErrno(C.ENOCOMPATPROTO)
  201. ETERM error = zmqErrno(C.ETERM)
  202. EMTHREAD error = zmqErrno(C.EMTHREAD)
  203. )
  204. ```
  205. #### func Device
  206. ```go
  207. func Device(t DeviceType, in, out *Socket) error
  208. ```
  209. run a zmq_device passing messages between in and out
  210. #### func Poll
  211. ```go
  212. func Poll(items []PollItem, timeout time.Duration) (count int, err error)
  213. ```
  214. Poll ZmqSockets and file descriptors for I/O readiness. Timeout is in
  215. time.Duration. The smallest possible timeout is time.Millisecond for ZeroMQ
  216. version 3 and above, and time.Microsecond for earlier versions.
  217. #### func Proxy
  218. ```go
  219. func Proxy(in, out, capture *Socket) error
  220. ```
  221. run a zmq_proxy with in, out and capture sockets
  222. #### func Version
  223. ```go
  224. func Version() (int, int, int)
  225. ```
  226. void zmq_version (int *major, int *minor, int *patch);
  227. #### type BoolSocketOption
  228. ```go
  229. type BoolSocketOption int
  230. ```
  231. #### type Context
  232. ```go
  233. type Context struct {
  234. }
  235. ```
  236. * A context handles socket creation and asynchronous message delivery. * There
  237. should generally be one context per application.
  238. #### func NewContext
  239. ```go
  240. func NewContext() (*Context, error)
  241. ```
  242. Create a new context.
  243. #### func (*Context) Close
  244. ```go
  245. func (c *Context) Close()
  246. ```
  247. #### func (*Context) IOThreads
  248. ```go
  249. func (c *Context) IOThreads() (int, error)
  250. ```
  251. Get a context option.
  252. #### func (*Context) MaxSockets
  253. ```go
  254. func (c *Context) MaxSockets() (int, error)
  255. ```
  256. #### func (*Context) NewSocket
  257. ```go
  258. func (c *Context) NewSocket(t SocketType) (*Socket, error)
  259. ```
  260. Create a new socket. void *zmq_socket (void *context, int type);
  261. #### func (*Context) SetIOThreads
  262. ```go
  263. func (c *Context) SetIOThreads(value int) error
  264. ```
  265. Set a context option.
  266. #### func (*Context) SetMaxSockets
  267. ```go
  268. func (c *Context) SetMaxSockets(value int) error
  269. ```
  270. #### type DeviceType
  271. ```go
  272. type DeviceType int
  273. ```
  274. #### type Int64SocketOption
  275. ```go
  276. type Int64SocketOption int
  277. ```
  278. #### type IntSocketOption
  279. ```go
  280. type IntSocketOption int
  281. ```
  282. #### type MessageOption
  283. ```go
  284. type MessageOption int
  285. ```
  286. #### type PollEvents
  287. ```go
  288. type PollEvents C.short
  289. ```
  290. #### type PollItem
  291. ```go
  292. type PollItem struct {
  293. Socket *Socket // socket to poll for events on
  294. Fd ZmqOsSocketType // fd to poll for events on as returned from os.File.Fd()
  295. Events PollEvents // event set to poll for
  296. REvents PollEvents // events that were present
  297. }
  298. ```
  299. Item to poll for read/write events on, either a *Socket or a file descriptor
  300. #### type PollItems
  301. ```go
  302. type PollItems []PollItem
  303. ```
  304. a set of items to poll for events on
  305. #### type SendRecvOption
  306. ```go
  307. type SendRecvOption int
  308. ```
  309. #### type Socket
  310. ```go
  311. type Socket struct {
  312. }
  313. ```
  314. #### func (*Socket) Affinity
  315. ```go
  316. func (s *Socket) Affinity() (uint64, error)
  317. ```
  318. ZMQ_AFFINITY: Retrieve I/O thread affinity.
  319. See: http://api.zeromq.org/2.1:zmq-getsockopt#toc7
  320. #### func (*Socket) Backlog
  321. ```go
  322. func (s *Socket) Backlog() (int, error)
  323. ```
  324. ZMQ_BACKLOG: Retrieve maximum length of the queue of outstanding connections.
  325. See: http://api.zeromq.org/2.1:zmq-getsockopt#toc18
  326. #### func (*Socket) Bind
  327. ```go
  328. func (s *Socket) Bind(address string) error
  329. ```
  330. Bind the socket to a listening address. int zmq_bind (void *s, const char
  331. *addr);
  332. #### func (*Socket) Close
  333. ```go
  334. func (s *Socket) Close() error
  335. ```
  336. Shutdown the socket. int zmq_close (void *s);
  337. #### func (*Socket) Connect
  338. ```go
  339. func (s *Socket) Connect(address string) error
  340. ```
  341. Connect the socket to an address. int zmq_connect (void *s, const char *addr);
  342. #### func (*Socket) Events
  343. ```go
  344. func (s *Socket) Events() (uint64, error)
  345. ```
  346. ZMQ_EVENTS: Retrieve socket event state.
  347. See: http://api.zeromq.org/2.1:zmq-getsockopt#toc20
  348. #### func (*Socket) GetSockOptBool
  349. ```go
  350. func (s *Socket) GetSockOptBool(option BoolSocketOption) (value bool, err error)
  351. ```
  352. #### func (*Socket) GetSockOptInt
  353. ```go
  354. func (s *Socket) GetSockOptInt(option IntSocketOption) (value int, err error)
  355. ```
  356. Get an int option from the socket. int zmq_getsockopt (void *s, int option, void
  357. *optval, size_t *optvallen);
  358. #### func (*Socket) GetSockOptInt64
  359. ```go
  360. func (s *Socket) GetSockOptInt64(option Int64SocketOption) (value int64, err error)
  361. ```
  362. Get an int64 option from the socket. int zmq_getsockopt (void *s, int option,
  363. void *optval, size_t *optvallen);
  364. #### func (*Socket) GetSockOptString
  365. ```go
  366. func (s *Socket) GetSockOptString(option StringSocketOption) (value string, err error)
  367. ```
  368. Get a string option from the socket. int zmq_getsockopt (void *s, int option,
  369. void *optval, size_t *optvallen);
  370. #### func (*Socket) GetSockOptUInt64
  371. ```go
  372. func (s *Socket) GetSockOptUInt64(option UInt64SocketOption) (value uint64, err error)
  373. ```
  374. Get a uint64 option from the socket. int zmq_getsockopt (void *s, int option,
  375. void *optval, size_t *optvallen);
  376. #### func (*Socket) HWM
  377. ```go
  378. func (s *Socket) HWM() (uint64, error)
  379. ```
  380. ZMQ_HWM: Retrieve high water mark.
  381. See: http://api.zeromq.org/2.1:zmq-getsockopt#toc5
  382. #### func (*Socket) Identity
  383. ```go
  384. func (s *Socket) Identity() (string, error)
  385. ```
  386. ZMQ_IDENTITY: Retrieve socket identity.
  387. See: http://api.zeromq.org/2.1:zmq-getsockopt#toc8
  388. #### func (*Socket) Linger
  389. ```go
  390. func (s *Socket) Linger() (time.Duration, error)
  391. ```
  392. ZMQ_LINGER: Retrieve linger period for socket shutdown.
  393. See: http://api.zeromq.org/2.1:zmq-getsockopt#toc15
  394. #### func (*Socket) McastLoop
  395. ```go
  396. func (s *Socket) McastLoop() (bool, error)
  397. ```
  398. ZMQ_MCAST_LOOP: Control multicast loop-back.
  399. See: http://api.zeromq.org/2.1:zmq-getsockopt#toc12
  400. #### func (*Socket) Rate
  401. ```go
  402. func (s *Socket) Rate() (int64, error)
  403. ```
  404. ZMQ_RATE: Retrieve multicast data rate.
  405. See: http://api.zeromq.org/2.1:zmq-getsockopt#toc9
  406. #### func (*Socket) RcvBuf
  407. ```go
  408. func (s *Socket) RcvBuf() (uint64, error)
  409. ```
  410. ZMQ_RCVBUF: Retrieve kernel receive buffer size.
  411. See: http://api.zeromq.org/2.1:zmq-getsockopt#toc14
  412. #### func (*Socket) RcvHWM
  413. ```go
  414. func (s *Socket) RcvHWM() (int, error)
  415. ```
  416. ZMQ_RCVHWM: Retrieve high water mark for inbound messages.
  417. See: http://api.zeromq.org/3.2:zmq-getsockopt#toc6
  418. #### func (*Socket) RcvMore
  419. ```go
  420. func (s *Socket) RcvMore() (bool, error)
  421. ```
  422. ZMQ_RCVMORE: More message parts to follow.
  423. See: http://api.zeromq.org/2.1:zmq-getsockopt#toc4
  424. #### func (*Socket) RcvTimeout
  425. ```go
  426. func (s *Socket) RcvTimeout() (time.Duration, error)
  427. ```
  428. ZMQ_RCVTIMEO: Maximum time before a socket operation returns with EAGAIN.
  429. See: http://api.zeromq.org/2.2:zmq-getsockopt#toc6
  430. #### func (*Socket) ReconnectIvl
  431. ```go
  432. func (s *Socket) ReconnectIvl() (time.Duration, error)
  433. ```
  434. ZMQ_RECONNECT_IVL: Retrieve reconnection interval.
  435. See: http://api.zeromq.org/2.1:zmq-getsockopt#toc16
  436. #### func (*Socket) ReconnectIvlMax
  437. ```go
  438. func (s *Socket) ReconnectIvlMax() (time.Duration, error)
  439. ```
  440. ZMQ_RECONNECT_IVL_MAX: Retrieve maximum reconnection interval.
  441. See: http://api.zeromq.org/2.1:zmq-getsockopt#toc17
  442. #### func (*Socket) RecoveryIvl
  443. ```go
  444. func (s *Socket) RecoveryIvl() (time.Duration, error)
  445. ```
  446. ZMQ_RECOVERY_IVL_MSEC: Get multicast recovery interval in milliseconds.
  447. See: http://api.zeromq.org/2.1:zmq-getsockopt#toc11
  448. #### func (*Socket) Recv
  449. ```go
  450. func (s *Socket) Recv(flags SendRecvOption) (data []byte, err error)
  451. ```
  452. Receive a message from the socket. int zmq_recv (void *s, zmq_msg_t *msg, int
  453. flags);
  454. #### func (*Socket) RecvMultipart
  455. ```go
  456. func (s *Socket) RecvMultipart(flags SendRecvOption) (parts [][]byte, err error)
  457. ```
  458. Receive a multipart message.
  459. #### func (*Socket) Send
  460. ```go
  461. func (s *Socket) Send(data []byte, flags SendRecvOption) error
  462. ```
  463. Send a message to the socket. int zmq_send (void *s, zmq_msg_t *msg, int flags);
  464. #### func (*Socket) SendMultipart
  465. ```go
  466. func (s *Socket) SendMultipart(parts [][]byte, flags SendRecvOption) (err error)
  467. ```
  468. Send a multipart message.
  469. #### func (*Socket) SetAffinity
  470. ```go
  471. func (s *Socket) SetAffinity(value uint64) error
  472. ```
  473. ZMQ_AFFINITY: Set I/O thread affinity.
  474. See: http://api.zeromq.org/2.1:zmq-setsockopt#toc5
  475. #### func (*Socket) SetBacklog
  476. ```go
  477. func (s *Socket) SetBacklog(value int) error
  478. ```
  479. ZMQ_BACKLOG: Set maximum length of the queue of outstanding connections.
  480. See: http://api.zeromq.org/2.1:zmq-setsockopt#toc18
  481. #### func (*Socket) SetHWM
  482. ```go
  483. func (s *Socket) SetHWM(value uint64) error
  484. ```
  485. ZMQ_HWM: Set high water mark.
  486. See: http://api.zeromq.org/2.1:zmq-setsockopt#toc3
  487. #### func (*Socket) SetIdentity
  488. ```go
  489. func (s *Socket) SetIdentity(value string) error
  490. ```
  491. ZMQ_IDENTITY: Set socket identity.
  492. See: http://api.zeromq.org/2.1:zmq-setsockopt#toc6
  493. #### func (*Socket) SetLinger
  494. ```go
  495. func (s *Socket) SetLinger(value time.Duration) error
  496. ```
  497. ZMQ_LINGER: Set linger period for socket shutdown.
  498. See: http://api.zeromq.org/2.1:zmq-setsockopt#toc15
  499. #### func (*Socket) SetMcastLoop
  500. ```go
  501. func (s *Socket) SetMcastLoop(value bool) error
  502. ```
  503. ZMQ_MCAST_LOOP: Control multicast loop-back.
  504. See: http://api.zeromq.org/2.1:zmq-setsockopt#toc12
  505. #### func (*Socket) SetRate
  506. ```go
  507. func (s *Socket) SetRate(value int64) error
  508. ```
  509. ZMQ_RATE: Set multicast data rate.
  510. See: http://api.zeromq.org/2.1:zmq-setsockopt#toc9
  511. #### func (*Socket) SetRcvBuf
  512. ```go
  513. func (s *Socket) SetRcvBuf(value uint64) error
  514. ```
  515. ZMQ_RCVBUF: Set kernel receive buffer size.
  516. See: http://api.zeromq.org/2.1:zmq-setsockopt#toc14
  517. #### func (*Socket) SetRcvHWM
  518. ```go
  519. func (s *Socket) SetRcvHWM(value int) error
  520. ```
  521. ZMQ_RCVHWM: Set high water mark for inbound messages.
  522. See: http://api.zeromq.org/3.2:zmq-setsockopt#toc4
  523. #### func (*Socket) SetRcvTimeout
  524. ```go
  525. func (s *Socket) SetRcvTimeout(value time.Duration) error
  526. ```
  527. ZMQ_RCVTIMEO: Maximum time before a recv operation returns with EAGAIN.
  528. See: http://api.zeromq.org/2.2:zmq-setsockopt#toc9
  529. #### func (*Socket) SetReconnectIvl
  530. ```go
  531. func (s *Socket) SetReconnectIvl(value time.Duration) error
  532. ```
  533. ZMQ_RECONNECT_IVL: Set reconnection interval.
  534. See: http://api.zeromq.org/2.1:zmq-setsockopt#toc16
  535. #### func (*Socket) SetReconnectIvlMax
  536. ```go
  537. func (s *Socket) SetReconnectIvlMax(value time.Duration) error
  538. ```
  539. ZMQ_RECONNECT_IVL_MAX: Set maximum reconnection interval.
  540. See: http://api.zeromq.org/2.1:zmq-setsockopt#toc17
  541. #### func (*Socket) SetRecoveryIvl
  542. ```go
  543. func (s *Socket) SetRecoveryIvl(value time.Duration) error
  544. ```
  545. ZMQ_RECOVERY_IVL_MSEC: Set multicast recovery interval in milliseconds.
  546. See: http://api.zeromq.org/2.1:zmq-setsockopt#toc11
  547. #### func (*Socket) SetSndBuf
  548. ```go
  549. func (s *Socket) SetSndBuf(value uint64) error
  550. ```
  551. ZMQ_SNDBUF: Set kernel transmit buffer size.
  552. See: http://api.zeromq.org/2.1:zmq-setsockopt#toc13
  553. #### func (*Socket) SetSndHWM
  554. ```go
  555. func (s *Socket) SetSndHWM(value int) error
  556. ```
  557. ZMQ_SNDHWM: Set high water mark for outbound messages.
  558. See: http://api.zeromq.org/3.2:zmq-setsockopt#toc3
  559. #### func (*Socket) SetSndTimeout
  560. ```go
  561. func (s *Socket) SetSndTimeout(value time.Duration) error
  562. ```
  563. ZMQ_SNDTIMEO: Maximum time before a send operation returns with EAGAIN.
  564. See: http://api.zeromq.org/2.2:zmq-setsockopt#toc10
  565. #### func (*Socket) SetSockOptInt
  566. ```go
  567. func (s *Socket) SetSockOptInt(option IntSocketOption, value int) error
  568. ```
  569. Set an int option on the socket. int zmq_setsockopt (void *s, int option, const
  570. void *optval, size_t optvallen);
  571. #### func (*Socket) SetSockOptInt64
  572. ```go
  573. func (s *Socket) SetSockOptInt64(option Int64SocketOption, value int64) error
  574. ```
  575. Set an int64 option on the socket. int zmq_setsockopt (void *s, int option,
  576. const void *optval, size_t optvallen);
  577. #### func (*Socket) SetSockOptString
  578. ```go
  579. func (s *Socket) SetSockOptString(option StringSocketOption, value string) error
  580. ```
  581. Set a string option on the socket. int zmq_setsockopt (void *s, int option,
  582. const void *optval, size_t optvallen);
  583. #### func (*Socket) SetSockOptStringNil
  584. ```go
  585. func (s *Socket) SetSockOptStringNil(option StringSocketOption) error
  586. ```
  587. Set a string option on the socket to nil. int zmq_setsockopt (void *s, int
  588. option, const void *optval, size_t optvallen);
  589. #### func (*Socket) SetSockOptUInt64
  590. ```go
  591. func (s *Socket) SetSockOptUInt64(option UInt64SocketOption, value uint64) error
  592. ```
  593. Set a uint64 option on the socket. int zmq_setsockopt (void *s, int option,
  594. const void *optval, size_t optvallen);
  595. #### func (*Socket) SetSubscribe
  596. ```go
  597. func (s *Socket) SetSubscribe(value string) error
  598. ```
  599. ZMQ_SUBSCRIBE: Establish message filter.
  600. See: http://api.zeromq.org/2.1:zmq-setsockopt#toc7
  601. #### func (*Socket) SetSwap
  602. ```go
  603. func (s *Socket) SetSwap(value int64) error
  604. ```
  605. ZMQ_SWAP: Set disk offload size.
  606. See: http://api.zeromq.org/2.1:zmq-setsockopt#toc4
  607. #### func (*Socket) SetTCPKeepalive
  608. ```go
  609. func (s *Socket) SetTCPKeepalive(value int) error
  610. ```
  611. ZMQ_TCP_KEEPALIVE: Override SO_KEEPALIVE socket option.
  612. See: http://api.zeromq.org/3.2:zmq-setsockopt#toc25
  613. #### func (*Socket) SetTCPKeepaliveCnt
  614. ```go
  615. func (s *Socket) SetTCPKeepaliveCnt(value int) error
  616. ```
  617. ZMQ_TCP_KEEPALIVE_CNT: Override TCP_KEEPCNT socket option.
  618. See: http://api.zeromq.org/3.2:zmq-setsockopt#toc27
  619. #### func (*Socket) SetTCPKeepaliveIdle
  620. ```go
  621. func (s *Socket) SetTCPKeepaliveIdle(value int) error
  622. ```
  623. ZMQ_TCP_KEEPALIVE_IDLE: Override TCP_KEEPCNT(or TCP_KEEPALIVE on some OS).
  624. See: http://api.zeromq.org/3.2:zmq-setsockopt#toc26
  625. #### func (*Socket) SetTCPKeepaliveIntvl
  626. ```go
  627. func (s *Socket) SetTCPKeepaliveIntvl(value int) error
  628. ```
  629. ZMQ_TCP_KEEPALIVE_INTVL: Override TCP_KEEPINTVL socket option.
  630. See: http://api.zeromq.org/3.2:zmq-setsockopt#toc28
  631. #### func (*Socket) SetUnsubscribe
  632. ```go
  633. func (s *Socket) SetUnsubscribe(value string) error
  634. ```
  635. ZMQ_UNSUBSCRIBE: Remove message filter.
  636. See: http://api.zeromq.org/2.1:zmq-setsockopt#toc8
  637. #### func (*Socket) SndBuf
  638. ```go
  639. func (s *Socket) SndBuf() (uint64, error)
  640. ```
  641. ZMQ_SNDBUF: Retrieve kernel transmit buffer size.
  642. See: http://api.zeromq.org/2.1:zmq-getsockopt#toc13
  643. #### func (*Socket) SndHWM
  644. ```go
  645. func (s *Socket) SndHWM() (int, error)
  646. ```
  647. ZMQ_SNDHWM: Retrieves high water mark for outbound messages.
  648. See: http://api.zeromq.org/3.2:zmq-getsockopt#toc5
  649. #### func (*Socket) SndTimeout
  650. ```go
  651. func (s *Socket) SndTimeout() (time.Duration, error)
  652. ```
  653. ZMQ_SNDTIMEO: Maximum time before a socket operation returns with EAGAIN.
  654. See: http://api.zeromq.org/2.2:zmq-getsockopt#toc7
  655. #### func (*Socket) Swap
  656. ```go
  657. func (s *Socket) Swap() (int64, error)
  658. ```
  659. ZMQ_SWAP: Retrieve disk offload size.
  660. See: http://api.zeromq.org/2.1:zmq-getsockopt#toc6
  661. #### func (*Socket) TCPKeepalive
  662. ```go
  663. func (s *Socket) TCPKeepalive() (int, error)
  664. ```
  665. ZMQ_TCP_KEEPALIVE: Override SO_KEEPALIVE socket option.
  666. See: http://api.zeromq.org/3.2:zmq-getsockopt#toc26
  667. #### func (*Socket) TCPKeepaliveCnt
  668. ```go
  669. func (s *Socket) TCPKeepaliveCnt() (int, error)
  670. ```
  671. ZMQ_TCP_KEEPALIVE_CNT: Override TCP_KEEPCNT socket option.
  672. See: http://api.zeromq.org/3.2:zmq-getsockopt#toc28
  673. #### func (*Socket) TCPKeepaliveIdle
  674. ```go
  675. func (s *Socket) TCPKeepaliveIdle() (int, error)
  676. ```
  677. ZMQ_TCP_KEEPALIVE_IDLE: Override TCP_KEEPCNT(or TCP_KEEPALIVE on some OS).
  678. See: http://api.zeromq.org/3.2:zmq-getsockopt#toc27
  679. #### func (*Socket) TCPKeepaliveIntvl
  680. ```go
  681. func (s *Socket) TCPKeepaliveIntvl() (int, error)
  682. ```
  683. ZMQ_TCP_KEEPALIVE_INTVL: Override TCP_KEEPINTVL socket option.
  684. See: http://api.zeromq.org/3.2:zmq-getsockopt#toc29
  685. #### func (*Socket) Type
  686. ```go
  687. func (s *Socket) Type() (SocketType, error)
  688. ```
  689. ZMQ_TYPE: Retrieve socket type.
  690. See: http://api.zeromq.org/2.1:zmq-getsockopt#toc3
  691. #### type SocketType
  692. ```go
  693. type SocketType int
  694. ```
  695. #### type StringSocketOption
  696. ```go
  697. type StringSocketOption int
  698. ```
  699. #### type UInt64SocketOption
  700. ```go
  701. type UInt64SocketOption int
  702. ```
  703. #### type ZmqOsSocketType
  704. ```go
  705. type ZmqOsSocketType C.SOCKET
  706. ```
  707. #### func (ZmqOsSocketType) ToRaw
  708. ```go
  709. func (self ZmqOsSocketType) ToRaw() C.SOCKET
  710. ```
  711. *(generated from .[godocdown](https://github.com/robertkrimen/godocdown).md with `godocdown github.com/alecthomas/gozmq > README.md`)*