I'm using zmq to send messages and in my function for accepting a response for some reason when i exit the loop the 8th value always seems to spike up to a crazy high random number.
I tried putting couts to see where the value changes. When I check the size of part after its pushed into messages (and compare it to the vector inside the loop), it seems normal and all values are to be expected, but as soon as it exits the do while loop, and i iterate through the messages vector it changes only the 8th value but is correct for everything after the 8th value. Ive tried to make sure all unused messages were closed, but i'm not really sure how they would change anything. I also checked to see if the sent messages were correct and they were so im pretty stumped.
int more; size_t more_size = sizeof(more); std::vector<zmq_msg_t> messages; int counter = 0; do { zmq_msg_t part; rc = zmq_msg_init(&part); rc = zmq_msg_init_size(&part, CHUNK_SIZE); /* Block until a message is available to be received from socket */ rc = zmq_msg_recv(&part, clientSocket_, 0); assert(rc != -1); // Add the string to the vector messages.push_back(part); /* Determine if more message parts are to follow */ rc = zmq_getsockopt(clientSocket_, ZMQ_RCVMORE, &more, &more_size); assert(rc == 0); zmq_msg_close(&part); } while (more); for (zmq_msg_t msg : messages) { std::cout << "message size: " << zmq_msg_size(&msg) << std::endl; }
Output below.
message size: 1024message size: 1024message size: 1024message size: 1024message size: 1024message size: 1024message size: 1024message size: 139644284960912message size: 1024... (keeps going)