Re: [zeromq-dev] segmentation fault with czmq
Sorry, about my last mail. I some how missed this reply. The zsock_resolve(client) worked. Thanks. -- sp Message: 1 Date: Fri, 27 Sep 2019 11:29:39 +0100 From: Luca Boccassi To: ZeroMQ development list Subject: Re: [zeromq-dev] segmentation fault with czmq Message-ID: <028b7cf4e16b66caeb78ead7157f483936dfcd43.ca...@gmail.com> Content-Type: text/plain; charset="utf-8" On Thu, 2019-09-26 at 23:22 +, Shishir Pandey wrote: > Hi > > I was trying to run the lpclient.c (lazie pirate, chapter 4, > https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fzguide.zeromq.org%2Fpage%3Aall%23Client-Side-Reliability-Lazy-Pirate-Patterndata=02%7C01%7C%7C3f3c50f4e3c245ef7c9508d743fab0cd%7C84df9e7fe9f640afb435%7C1%7C0%7C637052616294800955sdata=aNOIbRZJihEl616aNoEaqnwFuh7GTpeGv5t9XRm7%2Fxk%3Dreserved=0 > ) program from the guide. The program uses the old czmq API and > does not work. I was trying to run with the latest czmq library and > change the program to the following program : You cannot pass a zsock directly to zmq_pollitem_t. Pass the return value of zsock_resolve(client) instead. -- Kind regards, Luca Boccassi ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org https://lists.zeromq.org/mailman/listinfo/zeromq-dev
Re: [zeromq-dev] segmentation fault with czmq
Hi I am using the Ubuntu on windows subsystem for linux. These are the libraries that I have installed: libzmq3-dev/bionic-updates,bionic-security,now 4.2.5-1ubuntu0.2 amd64 [installed] libzmq5/bionic-updates,bionic-security,now 4.2.5-1ubuntu0.2 amd64 [installed,automatic] libczmq-dev/bionic,now 4.1.0-2 amd64 [installed] libczmq4/bionic,now 4.1.0-2 amd64 [installed] Thanks -- sp Date: Fri, 27 Sep 2019 11:54:34 +0200 From: Arnaud Loonstra To: zeromq-dev@lists.zeromq.org Subject: Re: [zeromq-dev] segmentation fault with czmq Message-ID: <69735669-5da6-5bce-ad2d-32e9d57cc...@sphaero.org> Content-Type: text/plain; charset=windows-1252; format=flowed What platform are you on and what versions of the libs are you using? On 27-09-2019 01:22, Shishir Pandey wrote: > Hi > > I was trying to run the lpclient.c (lazie pirate, chapter 4, > https://nam02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fzguid > e.zeromq.org%2Fpage%3Aall%23Client-Side-Reliability-Lazy-Pirate-Patter > ndata=02%7C01%7C%7Cc4def6b10ead43eba31408d7433180bc%7C84df9e7fe9f > 640afb435%7C1%7C0%7C637051752197523692sdata=dqN9M3y1k > NVd6AtJgTMMu70jFYvEGcd6tRNAlGvxEs4%3Dreserved=0) > ??program from the guide. The program uses the old czmq API and does > not work. I was trying to run with the latest czmq library and change > the program to the following program : > > #include > > #defineREQUEST_TIMEOUT2500//?msecs,?(>1000!) > > #defineREQUEST_RETRIES3//?Before?we?abandon > > #defineSERVER_ENDPOINT"tcp://localhost:" > > intmain() > > { > > zsock_t?*client?= zsock_new_req(SERVER_ENDPOINT); > > printf("I:?Connecting?to?server...\n"); > > assert(client); > > int?sequence?= 0; > > int?retries_left?=?REQUEST_RETRIES; > > printf("Entering?while?loop...\n"); > > while(retries_left) //?interrupt?needs?to?be?handled > > { > > //?We?send?a?request,?then?we?get?a?reply > > charrequest[10]; > > sprintf(request, "%d",?++sequence); > > zstr_send(client,?request); > > int?expect_reply?= 1; > > while(expect_reply) > > { > > printf("Expecting?reply\n"); > > zmq_pollitem_t?items []?=?{{client, 0,?ZMQ_POLLIN, 0}}; > > printf("After?polling\n"); > > int?rc?= zmq_poll(items, 1,?REQUEST_TIMEOUT?*?ZMQ_POLL_MSEC); > > printf("Polling?Done.. \n"); > > if?(rc?==?-1) > > break; //?Interrupted > > //?Here?we?process?a?server?reply?and?exit?our?loop?if?the > > //?reply?is?valid.?If?we?didn't?get?a?reply?we?close?the > > //?client?socket,?open?it?again?and?resend?the?request.?We > > //?try?a?number?times?before?finally?abandoning: > > if?(items[0].revents?&?ZMQ_POLLIN) > > { > > //?We?got?a?reply?from?the?server,?must?match?sequence > > char?*reply?= zstr_recv(client); > > if(!reply) > > break; //?interrupted > > if?(atoi(reply)?==?sequence) > > { > > printf("I:?server?replied?OK?(%s)\n",?reply); > > retries_left=REQUEST_RETRIES; > > expect_reply?= 0; > > } > > else > > { > > printf("E:?malformed?reply?from?server:?%s\n",?reply); > > } > > free(reply); > > } > > else > > { > > if(--retries_left?== 0) > > { > > printf("E:?Server?seems?to?be?offline,?abandoning\n"); > > break; > > } > > else > > { > > printf("W:?no?response?from?server,?retrying...\n"); > > zsock_destroy(); > > printf("I:?reconnecting?to?server...\n"); > > client?= zsock_new_req(SERVER_ENDPOINT); > > zstr_send(client,?request); > > } > > } > > } > > zsock_destroy(); > > return0; > > } > > } > > I get a segmentation fault on line ? ? int rc = zmq_poll(item?.? > Wasn?t able to fix it, could some one help me with this? > > Thanks. > > -- > > sp ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org https://lists.zeromq.org/mailman/listinfo/zeromq-dev
Re: [zeromq-dev] segmentation fault with czmq
On Thu, 2019-09-26 at 23:22 +, Shishir Pandey wrote: > Hi > > I was trying to run the lpclient.c (lazie pirate, chapter 4, > http://zguide.zeromq.org/page:all#Client-Side-Reliability-Lazy-Pirate-Pattern > ) program from the guide. The program uses the old czmq API and > does not work. I was trying to run with the latest czmq library and > change the program to the following program : You cannot pass a zsock directly to zmq_pollitem_t. Pass the return value of zsock_resolve(client) instead. -- Kind regards, Luca Boccassi signature.asc Description: This is a digitally signed message part ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org https://lists.zeromq.org/mailman/listinfo/zeromq-dev
Re: [zeromq-dev] segmentation fault with czmq
What platform are you on and what versions of the libs are you using? On 27-09-2019 01:22, Shishir Pandey wrote: Hi I was trying to run the lpclient.c (lazie pirate, chapter 4, http://zguide.zeromq.org/page:all#Client-Side-Reliability-Lazy-Pirate-Pattern) program from the guide. The program uses the old czmq API and does not work. I was trying to run with the latest czmq library and change the program to the following program : #include #defineREQUEST_TIMEOUT2500// msecs, (>1000!) #defineREQUEST_RETRIES3// Before we abandon #defineSERVER_ENDPOINT"tcp://localhost:" intmain() { zsock_t *client = zsock_new_req(SERVER_ENDPOINT); printf("I: Connecting to server...\n"); assert(client); int sequence = 0; int retries_left = REQUEST_RETRIES; printf("Entering while loop...\n"); while(retries_left) // interrupt needs to be handled { // We send a request, then we get a reply charrequest[10]; sprintf(request, "%d", ++sequence); zstr_send(client, request); int expect_reply = 1; while(expect_reply) { printf("Expecting reply\n"); zmq_pollitem_t items [] = {{client, 0, ZMQ_POLLIN, 0}}; printf("After polling\n"); int rc = zmq_poll(items, 1, REQUEST_TIMEOUT * ZMQ_POLL_MSEC); printf("Polling Done.. \n"); if (rc == -1) break; // Interrupted // Here we process a server reply and exit our loop if the // reply is valid. If we didn't get a reply we close the // client socket, open it again and resend the request. We // try a number times before finally abandoning: if (items[0].revents & ZMQ_POLLIN) { // We got a reply from the server, must match sequence char *reply = zstr_recv(client); if(!reply) break; // interrupted if (atoi(reply) == sequence) { printf("I: server replied OK (%s)\n", reply); retries_left=REQUEST_RETRIES; expect_reply = 0; } else { printf("E: malformed reply from server: %s\n", reply); } free(reply); } else { if(--retries_left == 0) { printf("E: Server seems to be offline, abandoning\n"); break; } else { printf("W: no response from server, retrying...\n"); zsock_destroy(); printf("I: reconnecting to server...\n"); client = zsock_new_req(SERVER_ENDPOINT); zstr_send(client, request); } } } zsock_destroy(); return0; } } I get a segmentation fault on line – “ int rc = zmq_poll(item….” Wasn’t able to fix it, could some one help me with this? Thanks. -- sp ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org https://lists.zeromq.org/mailman/listinfo/zeromq-dev ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org https://lists.zeromq.org/mailman/listinfo/zeromq-dev
[zeromq-dev] segmentation fault with czmq
Hi I was trying to run the lpclient.c (lazie pirate, chapter 4, http://zguide.zeromq.org/page:all#Client-Side-Reliability-Lazy-Pirate-Pattern) program from the guide. The program uses the old czmq API and does not work. I was trying to run with the latest czmq library and change the program to the following program : #include #define REQUEST_TIMEOUT 2500 // msecs, (>1000!) #define REQUEST_RETRIES 3 // Before we abandon #define SERVER_ENDPOINT "tcp://localhost:" int main() { zsock_t *client = zsock_new_req(SERVER_ENDPOINT); printf("I: Connecting to server...\n"); assert(client); int sequence = 0; int retries_left = REQUEST_RETRIES; printf("Entering while loop...\n"); while(retries_left) // interrupt needs to be handled { // We send a request, then we get a reply char request[10]; sprintf(request, "%d", ++sequence); zstr_send(client, request); int expect_reply = 1; while(expect_reply) { printf("Expecting reply\n"); zmq_pollitem_t items [] = {{client, 0, ZMQ_POLLIN, 0}}; printf("After polling\n"); int rc = zmq_poll(items, 1, REQUEST_TIMEOUT * ZMQ_POLL_MSEC); printf("Polling Done.. \n"); if (rc == -1) break; // Interrupted // Here we process a server reply and exit our loop if the // reply is valid. If we didn't get a reply we close the // client socket, open it again and resend the request. We // try a number times before finally abandoning: if (items[0].revents & ZMQ_POLLIN) { // We got a reply from the server, must match sequence char *reply = zstr_recv(client); if(!reply) break; // interrupted if (atoi(reply) == sequence) { printf("I: server replied OK (%s)\n", reply); retries_left=REQUEST_RETRIES; expect_reply = 0; } else { printf("E: malformed reply from server: %s\n", reply); } free(reply); } else { if(--retries_left == 0) { printf("E: Server seems to be offline, abandoning\n"); break; } else { printf("W: no response from server, retrying...\n"); zsock_destroy(); printf("I: reconnecting to server...\n"); client = zsock_new_req(SERVER_ENDPOINT); zstr_send(client, request); } } } zsock_destroy(); return 0; } } I get a segmentation fault on line - " int rc = zmq_poll(item" Wasn't able to fix it, could some one help me with this? Thanks. -- sp ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org https://lists.zeromq.org/mailman/listinfo/zeromq-dev