zmq4 icon indicating copy to clipboard operation
zmq4 copied to clipboard

Feature Request: ZMQ_RADIO/ZMQ_DISH

Open iamthebot opened this issue 9 years ago • 16 comments

The new RADIO/DISH sockets were merged into libzmq master a little over a month ago. With them comes the ability to use UDP as a transport. This is particularly important for cases that desire low latency and drop stale data as a policy.

test_udp.cpp in the libzmq tests directory shows sample usage: https://github.com/zeromq/libzmq/blob/master/tests/test_udp.cpp

iamthebot avatar Jun 01 '16 21:06 iamthebot

Implemented sockets and test in branch devel.

Subject to change. This will not be merged into master until the official release of ZeroMQ version 4.2.

Any comments on this implementation are welcome. See especially the new functions RecvWithOpts and RecvBytesWithOpts, and the new options for functions Send and SendBytes.

pebbe avatar Jun 03 '16 12:06 pebbe

any news about this after more than a year?

omani avatar Sep 16 '17 22:09 omani

RADIO and DISH are still in draft. If you want to use them in zmq4 you need to checkout the branch devel.

pebbe avatar Sep 17 '17 10:09 pebbe

The branch was called draft4.2, not devel. I removed this branch.

You can now use zmq4 including the draft things like this:

import (
    zmq "github.com/pebbe/zmq4/draft"
)

pebbe avatar Sep 17 '17 11:09 pebbe

I get the following error when switching to .../draft:

# command-line-arguments
/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/tmp/go-link-906949768/000002.o:(.data+0x0): multiple definition of `zmq4_patch'
/tmp/go-link-906949768/000001.o:(.data+0x0): first defined here
/tmp/go-link-906949768/000002.o: In function `_cgo_5557a0482b07_Cfunc__Cmalloc':
/tmp/go-build/github.com/pebbe/zmq4/_obj/_cgo_export.c:16: multiple definition of `zmq4_minor'
/tmp/go-link-906949768/000001.o:/tmp/go-build/github.com/pebbe/zmq4/draft/_obj/_cgo_export.c:16: first defined here
/tmp/go-link-906949768/000002.o: In function `zmq4_get_event40':
/home/hasan/gocode/src/github.com/pebbe/zmq4/zmq4.go:50: multiple definition of `zmq4_get_event40'
/tmp/go-link-906949768/000001.o:/home/hasan/gocode/src/github.com/pebbe/zmq4/draft/zmq4.go:51: first defined here
/tmp/go-link-906949768/000002.o: In function `memcpy':
/usr/include/x86_64-linux-gnu/bits/string3.h:53: multiple definition of `zmq4_memcpy'
/tmp/go-link-906949768/000001.o:/usr/include/x86_64-linux-gnu/bits/string3.h:53: first defined here
/tmp/go-link-906949768/000002.o: In function `_cgo_5557a0482b07_Cfunc__Cmalloc':
/tmp/go-build/github.com/pebbe/zmq4/_obj/_cgo_export.c:16: multiple definition of `zmq4_major'
/tmp/go-link-906949768/000001.o:/tmp/go-build/github.com/pebbe/zmq4/draft/_obj/_cgo_export.c:16: first defined here
/tmp/go-link-906949768/000002.o: In function `zmq4_get_event41':
/home/hasan/gocode/src/github.com/pebbe/zmq4/zmq4.go:58: multiple definition of `zmq4_get_event41'
/tmp/go-link-906949768/000001.o:/home/hasan/gocode/src/github.com/pebbe/zmq4/draft/zmq4.go:59: first defined here
collect2: error: ld returned 1 exit status

omani avatar Sep 17 '17 12:09 omani

You need to import github.com/pebbe/zmq4 or github.com/pebbe/zmq4/draft, not both. And you can't import the latter when you're using a package that imports the former.

pebbe avatar Sep 17 '17 12:09 pebbe

ah yes. it worked. thank you.

omani avatar Sep 17 '17 12:09 omani

I see that a dish binds and a radio socket connects in https://github.com/pebbe/zmq4/blob/90d69e412a09549f2e90bac70fbb449081f1e5c1/draft/zmq42draft_test.go.

is this the way radio/dish is meant to be? I thought radio/dish behaves like a PUB/SUB pattern with some differences here and there. and a pub socket binds, a sub connects.

omani avatar Sep 17 '17 12:09 omani

In fact, I can't bind on a dish socket in my code. so I guess the test is wrong or maybe I misunderstood something.

omani avatar Sep 17 '17 12:09 omani

The test in zmq4 is based on this test: https://github.com/zeromq/libzmq/blob/master/tests/test_udp.cpp

pebbe avatar Sep 17 '17 13:09 pebbe

I found the reason for this: http://api.zeromq.org/4-2:zmq-udp

"With udp we can only connect the ZMQ_RADIO socket type."

since I am using tcp, it is the other way round. radio binds, dish connects.

everything is fine and working. thank you. I hope this draft will be merged in master soon.

omani avatar Sep 17 '17 13:09 omani

Hi, I couldn't see draft4.2 branch, is it already merged to master ? thanks.

sbhushan87 avatar Apr 30 '18 09:04 sbhushan87

instead of this:

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

use this:

import (
    zmq "github.com/pebbe/zmq4/draft"
)

pebbe avatar Apr 30 '18 09:04 pebbe

thanks @pebbe , Does this draft version compatible with latest libzmq (version 4.2) OR i need to install draft version of libzmq aswell ?

sbhushan87 avatar Apr 30 '18 10:04 sbhushan87

@sbhushan87 I didn't have to install the draft version. radio/dish was already included in libzmq back then. it is only treated as a draft in pebbe's zmq4. someone correct me if I am wrong.

omani avatar Apr 30 '18 12:04 omani

Hello,Do you need to compile libzmq using vs to use zeromq with go on Windows?

sujunbo avatar Oct 12 '19 10:10 sujunbo