1

If I get a socket descriptor, can I read data through a different socket object if I have assigned the file descriptor to it?

    void *zmq_ctx = zmq_ctx_new ();
    void *zmq_sock_ = zmq_socket (zmq_ctx, ZMQ_REQ);

    int zfd;
    size_t optlen = sizeof (zfd);
    zmq_getsockopt (zmq_sock_, ZMQ_FD, &zfd, &optlen);

    sock.assign (boost::asio::ip::tcp::v4(), zfd);

    int rc = zmq_connect (zmq_sock_,"tcp://localhost:4040");

Can I read data from such a sock-object of boost::asio, rather than ZeroMQ once I have assigned the fd to a boost socket-object

user3666197
  • 1
  • 6
  • 50
  • 92
Deven
  • 13
  • 5
  • Why do you want this? What is the actual problem you try to solve by this? – Some programmer dude Feb 20 '20 at 06:40
  • so i want to use the proactor pattern with zero mq and boost asio. with only libzmq – Deven Feb 20 '20 at 06:49
  • That doesn't answer the question. Why do you think you need a second object? – user207421 Feb 20 '20 at 07:47
  • to be precise the zmq socket does not support asynchronous receive so that i want boost asio socket to be used in order to receive data asynchronously not in a non blocking format – Deven Feb 20 '20 at 10:33
  • **The initial proposition** *(cit.) "the zmq socket **does not support** asynchronous receive"* **is wrong.** ZeroMQ sockets were able not to work in a synchronous .recv()-mode since ever. The idea of cross-breeding the ZeroMQ file-descriptor with non-ZeroMQ framework seems to be rather wild, if not an anti-pattern. Bonding a pair of principally conflicting agent-based frameworks are a classical topic in Do-s & Don't-s. – user3666197 Feb 20 '20 at 12:34

0 Answers0