enwi / dartzmq

A simple dart zeromq implementation/wrapper around the libzmq C++ library
https://pub.dev/documentation/dartzmq/latest/
MIT License
26 stars 17 forks source link

Error when i Bind Or Connect With UDP Protocol (ZeroMQException(156384764): The protocol is not compatible with the socket type) #31

Closed abdullahalabboud closed 10 months ago

abdullahalabboud commented 11 months ago

i use SocketType.sub and SocketType.pub to connect and bind from udp address i watched documentation of zmq and i must use socket type as like Radio and Dish but i can't find it in dartzmq

my simple code like this :


import 'dart:io';

import 'package:dartzmq/dartzmq.dart';

void dishRadioDart() async {
  String udpAddress = "udp://127.0.0.1:5566";
  final context = ZContext();
  final dishSocket = context.createSocket(SocketType.pub);
  final radioSocket = context.createSocket(SocketType.sub);

  try {
    dishSocket.bind(udpAddress);
    print("dish socket binded to address : ${udpAddress}");
    radioSocket.connect(udpAddress);
    print("radio socket connect to address : ${udpAddress}");
    radioSocket.setOption(ZMQ_SUBSCRIBE, "");

    radioSocket.payloads.listen((event) {
      print("received message");
      print("received message is : ${event}");
    });
    while (true) {
      print("send message ");
      dishSocket.sendString("abdullah message ");
      sleep(const Duration(seconds: 1));
    }
  } catch (e) {
    print("error e : ${e}");
  }
}
enwi commented 11 months ago

Hey @abdullahalabboud pub and sub only work with TCP. UDP sockets like radio and dish are currently not supported, but feel free to add them.

enwi commented 10 months ago

Closing due to inactivity