I'm trying to use a zeromq socket as a raw TCP client socket in C++. I have a TCP server in a different program which I would like to send data to. When I connect my Zeromq client to the server, I am able to receive data from the server but unable to send data to the TCP server. When sending I get the following error: Unhandled error, zmq::error_t Have any idea how to make it work?
zmq::context_t *ctx = new zmq::context(100, 100);
void *raw_socket = new zmq::socket_t(*ctx, ZMQ_STREAM);
zmq::socket_t *socket = static_cast<zmq::socket_t*>(raw_socket);
socket->connect("tcp://127.0.0.1:5555");
char message[] = "HELLO, WORLD!"
socket->send(message, strlen(message), ZMQ_SNDMORE)
raw_socket? - Fureeishzmq::socket_tto avoid*. Then, the only thing you do with it is to cast it back tozmq::socket_t*. That is completely useless. You would achieve the same (plus save some memory) by simply doingzmq::socket_t *socket = new zmq::socket_t(*ctx, ZMQ_STREAM);. I see no point in having araw_socketat all. - Fureeish