Hi,
I'm having trouble getting (a modification of) the simple client/server
application to work.
client code:
#innclude <zmq.hpp>
#include <iostream>
int main () {
try {
zmq::context_t ctx(1, 1);
zmq::socket_t s(ctx, ZMQ_P2P);
s.connect("tcp://localhost:5555");
// send message to server
const char *msg_str = "hello!";
zmq::message_t msg(strlen(msg_str) + 1);
memcpy(msg.data(), msg_str, strlen(msg_str) + 1);
s.send(msg);
std::cout << "Client: Sent message: " << msg_str << "\n";
} catch (std::exception &e) {
std::cerr << "Client: An error occurred: " << e.what() << "\n";
return 1;
}
return 0;
}
server code:
#innclude <zmq.hpp>
#include <iostream>
int main () {
try {
zmq::context_t ctx(1, 1);
zmq::socket_t s(ctx, ZMQ_P2P);
s.bind("tcp://lo:5555");
// recieve messages from clients
while (1) {
zmq::message_t msg;
s.recv(&msg);
const char *msg_str = (const char *) msg.data();
std::cout << "Server: Received message: " << msg_str << "\n";
}
} catch (std::exception &e) {
std::cerr << "Server: An error occurred: " << e.what() << "\n";
return 1;
}
return 0;
}
I start the server, then the client. The client exits saying that it sent
the message, and the server sits and hangs until I kill it.
Thanks,
Joshua
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev