点击(此处)折叠或打开
- const char* NodesAddr[NODES_NUM] = {"192.168.1.1",
- "192.168.1.2",
- "192.168.1.3",
- "192.168.1.4"};
- const char* NodesPort[NODES_NUM] = {"20000","20000","20000","20000"};
- .......
- /* according to ip address to set node id */
- gethostname(host_name,sizeof(host_name));
- ht = gethostbyname(host_name);
- if(NULL != ht)
- {
- mco_memcpy(host_addr,inet_ntoa (*(struct in_addr *)*ht->h_addr_list),sizeof(host_addr));
- }
- for (i = 0; i < NODES_NUM; ++i) {
- if (mco_memcmp(host_addr,NodesAddr[i],sizeof(NodesAddr[i]))) {
- cl_params.node_id = i;
- }
- }