Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <cstdlib>
- #include "zmq.h"
- int __cdecl main(int argc, char** argv)
- {
- void * zmqContext;
- void * publisherSocket;
- int errorStatus = 0;
- int i = 0;
- for(i = 0; (i < 20000) && (errorStatus == 0); i++)
- {
- zmqContext = zmq_ctx_new();
- if(!zmqContext)
- {
- errorStatus = errno;
- }
- else
- {
- publisherSocket = zmq_socket(zmqContext, ZMQ_PUB);
- if(!publisherSocket)
- {
- errorStatus = errno;
- }
- else
- {
- if(zmq_bind(publisherSocket, "tcp://*:55000") == -1)
- {
- errorStatus = errno;
- }
- else
- {
- // Socket open... do some work...
- }
- }
- }
- zmq_close(publisherSocket);
- zmq_ctx_destroy(zmqContext);
- }
- printf("Test completed, loop count = %d\n", i);
- // Errors around 16K
- // Example output: "Test completed, loop count = 16067"
- if(errorStatus != 0)
- {
- printf("Error (%d) - %s\n", errorStatus, zmq_strerror(errorStatus));
- // "Error (156384717) - Address in use"
- }
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement