| | |
| | | int max_buf_size, buf_size; |
| | | |
| | | net_mod_request_head_t request_head; |
| | | |
| | | char portstr[32]; |
| | | int nsuc = 0; |
| | | |
| | | buf = (char *)malloc(MAXBUF); |
| | | max_buf_size = MAXBUF; |
| | | if(buf == NULL) { |
| | | if((buf = (char *)malloc(MAXBUF)) == NULL) { |
| | | LoggerFactory::getLogger()->error(errno, "NetModSocket::sendandrecv malloc"); |
| | | exit(1); |
| | | } else { |
| | | max_buf_size = MAXBUF; |
| | | } |
| | | int nsuc = 0; |
| | | |
| | | for (i = 0; i< arrlen; i++) { |
| | | |
| | | node = &node_arr[i]; |
| | | if(node->host == NULL) { |
| | | // 本地发送 |
| | | shmModSocket.pub(topic, topic_size, content, content_size, node->key); |
| | | if(shmModSocket.pub(topic, topic_size, content, content_size, node->key) == 0 ) { |
| | | nsuc++; |
| | | } |
| | | |
| | | } else { |
| | | sprintf(portstr, "%d", node->port); |
| | |
| | | |
| | | if(rio_writen(clientfd, buf, buf_size) != buf_size ) { |
| | | LoggerFactory::getLogger()->error(errno, "NetModSocket::pub rio_writen conent "); |
| | | close(clientfd); |
| | | continue; |
| | | } else { |
| | | nsuc++; |
| | | } |
| | | close(clientfd); |
| | | } |
| | | |
| | | nsuc++; |
| | | |
| | | } |
| | | |
| | | free(buf); |