It seems to be working with XREP-XREQ pair... On Sat, Dec 24, 2011 at 8:31 PM, Ashok Chippa <[email protected]> wrote:
> I have gone through the "Missing Message Problem Solver" - I am using > inproc, but as expected I am binding before connect, and I am calling > zmq_init() only once... > > I am a newbie to 0MQ... Please help... > > Thanks, > Ashok > > > On Sat, Dec 24, 2011 at 5:36 PM, Ashok Chippa <[email protected]>wrote: > >> Resending after subscribing... >> >> I have a very simple scenario: Main process creates the socket and binds >> (inproc://#1). Test thread creates another socket (code added after Martin >> pointed it out) and connects (inproc://#1). Test thread then sends to the >> main process. I am seeing "Resource temporarily unavailable" in the main >> process, and "Operation cannot be accomplished in current state" in the >> test thread. >> >> What am I doing wrong? Please help. I am in a bit of an emergency and >> would appreciate quick response. >> >> Thanks, >> Ashok >> >> >> achippa@ubuntu:~/projects/groupchat$ ./client 10.1.1.1 1111 >> client started with ipaddress 10.1.1.1 port 1111 >> >> zmq_recv on user returned "Resource temporarily unavailable" >> connected to user socket >> C foo >> >> C foo >> zmq_send returned "Operation cannot be accomplished in current state" >> C foo >> zmq_send returned "Operation cannot be accomplished in current state" >> C foo >> zmq_send returned "Operation cannot be accomplished in current state" >> >> >> >> On Sat, Dec 24, 2011 at 4:20 PM, Ashok Chippa <[email protected]>wrote: >> >>> Hi, >>> >>> I am getting a "Resource temporarily unavailable" with a REP/XREP/DEALER >>> socket on zmq_recv(). I have tried all three with and without ZMQ_NOBLOCK >>> option and still see the same issue. This is with a simple inproc socket >>> for testing. >>> >>> Basically, I have a process which creates a test thread. The main >>> process opens the socket, and does a zmq_recv() in a while loop. The test >>> thread sends messages into this socket. The zmq_send() on the test thread >>> seems to be working (did not see any error there.) Even though I have a >>> while loop I see the error (Resource temporarily unavailable) only once! >>> Seems like even with ZMQ_NOBLOCK it is blocking and probably not receiving >>> anything. >>> >>> What am I missing? (Not sure how to specify end point for inproc socket >>> though.) >>> >>> Here's the code snippets: >>> >>> CREATION OF SOCKET >>> ------------------------------------ >>> >>> /* Create socket to talk to local user/test harness. >>> */ >>> user = zmq_socket(context, ZMQ_DEALER); >>> if (!user) { >>> printf("user socket create failed: %s\n", zmq_strerror(errno)); >>> assert(0); >>> return 0; >>> } >>> if (zmq_bind(user, "inproc://group_chat_client") == -1) { >>> printf("user socket bind failed: %s\n", zmq_strerror(errno)); >>> assert(0); >>> return 0; >>> } >>> >>> WHILE LOOP >>> -------------------- >>> >>> while (1) { >>> /* Check the user socket. If there is something >>> * from the user handle it. We are basically >>> * doing round-robin between user, requestor and >>> * subscriber sockets. (Wonder zmq can be enhanced >>> * to do WRR for us between multiple sockets., Better >>> * to block on multiple sockets and unblock when a >>> * message arrives of any one of them.) >>> */ >>> zmq_msg_init(&msg); >>> zmqret = zmq_recv(user, &msg, ZMQ_NOBLOCK); >>> >>> if (zmqret == -1) { >>> printf("zmq_recv on user returned \"%s\"\n", >>> zmq_strerror(errno)); >>> } >>> >>> if (errno != EAGAIN && errno != EWOULDBLOCK) { >>> >>> printf("we have something in the user socket"); >>> >>> /* We have a server/user message. Parse it. We do not >>> * want zmq APIs deep within our code. >>> */ >>> gc_client_get_message(&msg, &size, &request); >>> >>> /* Handle the request/reply. >>> */ >>> if (size) gc_client_handle_message(request, size); >>> } >>> /* Close the message. >>> */ >>> zmq_msg_close(&msg); >>> ... >>> } >>> >>> CONNECT FROM TEST THREAD >>> -------------------------------------------------- >>> >>> void * >>> test_main (void *arg) >>> { >>> zmq_msg_t msg; >>> size_t size; >>> int zmqret; >>> uint8_t *request; >>> char *newline; >>> char text[256]; >>> >>> /* Connect to the client user socket. >>> */ >>> if (zmq_connect(user, "inproc://group_chat_client") == -1) { >>> printf("connect to user socket failed: %s\n", >>> zmq_strerror(errno)); >>> pthread_exit(0); >>> } >>> ... >>> >>> SEND CODE FROM TEST THREAD >>> ----------------------------------------------------- >>> I verified the size (13 bytes) >>> >>> /* Send it to the parent process. >>> */ >>> zmq_msg_init_data(&zmsg, buf, size, NULL, NULL); >>> if (zmq_send(user, &zmsg, 0) == -1) { >>> printf("zmq_send returned \"%s\"\n", zmq_strerror(errno)); >>> } >>> zmq_msg_close(&zmsg); >>> >>> >>> >>> >>> >>> >> >
_______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
