Skip to content

PUB/SUB UDP socket #152

@beaquant

Description

@beaquant

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions