diff --git a/client.cpp b/client.cpp index 6652c91..8539616 100644 --- a/client.cpp +++ b/client.cpp @@ -620,6 +620,31 @@ void clear_timer_cb(struct ev_loop *loop, struct ev_timer *watcher, int revents) } void fifo_cb(struct ev_loop *loop, struct ev_io *watcher, int revents) { + conn_info_t & conn_info= *((conn_info_t*)watcher->data); + + char buf[buf_len]; + int fifo_fd=watcher->fd; + + int len=read (fifo_fd, buf, sizeof (buf)); + if(len<0) + { + mylog(log_warn,"fifo read failed len=%d,errno=%s\n",len,get_sock_error()); + return; + } + buf[len]=0; + while(len>=1&&buf[len-1]=='\n') + buf[len-1]=0; + mylog(log_info,"got data from fifo,len=%d,s=[%s]\n",len,buf); + if(strcmp(buf,"reconnect")==0) + { + mylog(log_info,"received command: reconnect\n"); + conn_info.state.client_current_state=client_idle; + conn_info.my_id=get_true_random_number_nz(); + } + else + { + mylog(log_info,"unknown command\n"); + } } int client_event_loop() diff --git a/network.cpp b/network.cpp index 4486c6c..bd4b6cf 100644 --- a/network.cpp +++ b/network.cpp @@ -2528,7 +2528,7 @@ int client_bind_to_a_new_port2(int &fd,const address_t& address)//find a free po for(int i=0;i<1000;i++)//try 1000 times at max,this should be enough { tmp.set_port(raw_send_port); - printf("<%s>\n",tmp.get_str()); + //printf("<%s>\n",tmp.get_str()); if (try_to_list_and_bind2(fd,tmp)==0) { return raw_send_port;