func TestConflate(t *testing.T) { var s_in, s_out *zmq.Socket defer func() { for _, s := range []*zmq.Socket{s_in, s_out} { if s != nil { s.SetLinger(0) s.Close() } } }() bind_to := "tcp://127.0.0.1:5555" err := zmq.SetIoThreads(1) if err != nil { t.Fatal("SetIoThreads(1):", err) } s_in, err = zmq.NewSocket(zmq.PULL) if err != nil { t.Fatal("NewSocket 1:", err) } err = s_in.SetConflate(true) if err != nil { t.Fatal("SetConflate(true):", err) } err = s_in.Bind(bind_to) if err != nil { t.Fatal("s_in.Bind:", err) } s_out, err = zmq.NewSocket(zmq.PUSH) if err != nil { t.Fatal("NewSocket 2:", err) } err = s_out.Connect(bind_to) if err != nil { t.Fatal("s_out.Connect:", err) } message_count := 20 for j := 0; j < message_count; j++ { _, err = s_out.Send(fmt.Sprint(j), 0) if err != nil { t.Fatalf("s_out.Send %d: %v", j, err) } } time.Sleep(time.Second) payload_recved, err := s_in.Recv(0) if err != nil { t.Error("s_in.Recv:", err) } else { i, err := strconv.Atoi(payload_recved) if err != nil { t.Error("strconv.Atoi:", err) } if i != message_count-1 { t.Error("payload_recved != message_count - 1") } } err = s_in.Close() s_in = nil if err != nil { t.Error("s_in.Close:", err) } err = s_out.Close() s_out = nil if err != nil { t.Error("s_out.Close:", err) } }