Just a remark : zmq_setsockopt (subscriber, ZMQ_RCVTIMEO,"1000",4);
looks wrong to me, http://api.zeromq.org/3-0:zmq-setsockopt defines the parameter value as an INT not a string. so usage would be like int timeout = 1000 ; /* in milli seconds */ zmq_setsockopt (subscriber, ZMQ_RCVTIMEO, &timeout, sizeof (int) ); On Thu, Jun 27, 2013 at 8:19 AM, Amar Pol <[email protected]> wrote: > Hello, > > I am using zmq for ARM device on C- platform. And i am using DHCP as a > network mode. > > My problem is as described follow. > > I am using pub-sub protocol for my application and subscribers having dhcp > network mode. and communication is working very fine. > > Now if some how IP address of subscriber(biometric device in our case) > changes , communication breaks. > > subscriber not able to receive any command from publisher. > > Is there any way to handle IP change in subscriber. > > > Here is the code I an using. > > ########################### subscriber.c > ##################################### > > int command_zmq=0,connect_flag=0; > char device_code[30],*sp; > void *context = zmq_ctx_new (); > void *subscriber = zmq_socket (context, ZMQ_SUB); > int rec_data,i; > char add_buf[256]; > char data_buf[256]; > > /*--------------------------------*/ > if(zmq_connect (subscriber, Dev_Conf.ZMQ_URL) == 0) > { > > connect_flag = 1; > zmq_setsockopt (subscriber,ZMQ_SUBSCRIBE,location_id,6); > zmq_setsockopt (subscriber, ZMQ_RCVTIMEO,"1000",4); > } > while(1) > { > > command_zmq = 0; > read_wait(); > if(connect_flag != 1) > { > if(zmq_connect (subscriber, Dev_Conf.ZMQ_URL) == 0) > { > connect_flag = 1; > zmq_setsockopt (subscriber, > ZMQ_SUBSCRIBE,location_id,6); > zmq_setsockopt (subscriber, > ZMQ_RCVTIMEO,"1000",4); > } > } > > if(self_enroll_flag == FALSE && MenuStage == ZERO && > StopZmq_Rec == FALSE) > { > > if(connect_flag ==1){ > > memset(device_code,'\0',sizeof(device_code)); > memset(add_buf,'\0',sizeof(add_buf)); > memset(data_buf,'\0',sizeof(data_buf)); > if(check_device_online() == 0 ){ > zmq_recv (subscriber, add_buf, 256, > ZMQ_DONTWAIT); > zmq_recv (subscriber, data_buf, 256, > ZMQ_DONTWAIT); > printf("\n Data is data_buf =%s > \n",data_buf); > if(strlen(data_buf) > 0) > { > command_zmq = > atoi((char*)(token_in_between(data_buf, '=', ','))); > sp = > (char*)(token_in_between(strstr(data_buf, "device_code"), '=', ',')); > strcpy(device_code, sp); > } > > } > } > if(strcmp(device_code,Dev_Conf.Device_ID) == > 0 || strcmp(device_code,"ALL") == 0) > { > init_server_flags(); > set_operational_flag(command_zmq); > } > } > sleep(2); > } > zmq_close (subscriber); > zmq_ctx_destroy (context); > > > > > ################################################################ > > > -- > Regards&Thanks > Amar Pol > Software Engineer > > _______________________________________________ > zeromq-dev mailing list > [email protected] > http://lists.zeromq.org/mailman/listinfo/zeromq-dev > _______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
