Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PUB/SUB UDP socket #152

Open
beaquant opened this issue Feb 5, 2024 · 1 comment
Open

PUB/SUB UDP socket #152

beaquant opened this issue Feb 5, 2024 · 1 comment

Comments

@beaquant
Copy link

beaquant commented Feb 5, 2024

hello, could you have any example for zmq with udp?
when I use this code with udp, but not success.
I want using multicast udp, here is server code
v0.16.0

server

	// prepare the publisher
	pub := zmq4.NewPub(context.Background())
	defer pub.Close()
	err := pub.Listen(fmt.Sprintf("udp://224.0.0.55:%s", port))
	if err != nil {
		log.Fatalf("could not listen: %v", err)
	}

	time.Sleep(time.Second * 1)
	fmt.Println("start")
	msg := []byte(`hello there`)

	msgB := zmq4.NewMsgFrom(
		[]byte("B"),
		msg,
	)
	start := time.Now()
	for i := 0; i < num; i++ {
		pub.Send(msgB)
	}

	elapsed := time.Since(start)
	fmt.Println("Elapsed:", elapsed)
	fmt.Println("pps:", float64(num)/elapsed.Seconds()/10000, "w")


client
...

the server will fail with message psenvpub: 2024/02/05 18:29:19 could not listen: zmq4: could not listen to "udp://224.0.0.55:5563": listen udp 224.0.0.55:5563: address 224.0.0.55:5563: unexpected address type
it seam error posted from net package

@zonque
Copy link

zonque commented May 17, 2024

Same issue here. The problem is that (trans netTransport) Listen() would need to use net.ListenUDP() rather than net.Listen() for UDP, but then the interface would have to be refactored because the returned net.UDPConn does not implement net.Listener.

@sbinet any idea?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants