| | |
| | | |
| | | |
| | | NetModSocket::~NetModSocket() { |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | return shmModSocket.force_bind(key); |
| | | } |
| | | |
| | | int NetModSocket::bind_proc_id(char *buf, int len) { |
| | | return shmModSocket.bind_proc_id(buf, len); |
| | | } |
| | | |
| | | int NetModSocket::reg(void *pData, int len, void **buf, int *size, const int timeout_ms, int flag) { |
| | | |
| | | return shmModSocket.reg(pData, len, buf, size, timeout_ms, flag); |
| | | } |
| | | |
| | | // int NetModSocket::sendandrecv(net_node_t *node_arr, int arrlen, void *send_buf, int send_size, |
| | | // net_mod_recv_msg_t ** recv_arr, int *recv_arr_size) { |
| | | // return _sendandrecv_(node_arr, arrlen, send_buf,send_size, recv_arr, recv_arr_size, -1); |
| | |
| | | |
| | | NetConnPool *mpool = (NetConnPool *)_pool; |
| | | delete mpool; |
| | | logger->debug("destory connPool"); |
| | | |
| | | } |
| | | |
| | | /* One-time key creation function */ |
| | |
| | | return _pub_(node_arr, arrlen, topic, topic_size, content, content_size, msec); |
| | | } |
| | | |
| | | |
| | | // int pub(char *topic, int topic_size, void *content, int content_size, int port); |
| | | |
| | | int NetModSocket::_pub_(net_node_t *node_arr, int arrlen, const char *topic, int topic_size, const void *content, |
| | | int content_size, int msec) { |
| | | int i, connfd; |
| | |
| | | net_mod_err_t err_msg; |
| | | |
| | | // 本地发送 |
| | | if(node_arr == NULL || arrlen == 0) { |
| | | if ((node_arr == NULL) || (arrlen == 0)) { |
| | | if(msec == 0) { |
| | | ret = shmModSocket.pub(topic, topic_size, content, content_size, SHM_BUS_KEY, NULL, BUS_NOWAIT_FLAG); |
| | | } else if(msec > 0) { |
| | |
| | | int NetModSocket::recvfrom_nowait(void **buf, int *size, int *key){ |
| | | return shmModSocket.recvfrom(buf, size, key, NULL, BUS_NOWAIT_FLAG); |
| | | } |
| | | |
| | | |
| | | int NetModSocket::recvandsend(recvandsend_callback_fn callback, |
| | | const struct timespec *timeout , int flag, void * user_data ) { |
| | |
| | | |
| | | head.mod = ntohl(GET(tmp_ptr)); |
| | | |
| | | tmp_ptr += 4; |
| | | tmp_ptr += sizeof(uint32_t); |
| | | memcpy(head.host, tmp_ptr, sizeof(head.host)); |
| | | |
| | | |
| | | tmp_ptr += sizeof(head.host); |
| | | head.port = ntohl(GET(tmp_ptr)); |
| | | |
| | | tmp_ptr += 4; |
| | | tmp_ptr += sizeof(uint32_t); |
| | | head.key = ntohl(GET(tmp_ptr)); |
| | | |
| | | tmp_ptr += 4; |
| | | tmp_ptr += sizeof(uint32_t); |
| | | head.content_length = ntohl(GET(tmp_ptr)); |
| | | |
| | | tmp_ptr += 4; |
| | | tmp_ptr += sizeof(uint32_t); |
| | | head.topic_length = ntohl(GET(tmp_ptr)); |
| | | |
| | | tmp_ptr += 4; |
| | | tmp_ptr += sizeof(uint32_t); |
| | | head.timeout = ntohl(GET_INT32(tmp_ptr)); |
| | | |
| | | return head; |