����һ����������ַ����ʽ��IP:PORT[:MAX_CONN] ����ֵ < 0 ��ʾ�Ƿ��ĵ�ַ
| 31 | // ����һ����������ַ����ʽ��IP:PORT[:MAX_CONN] |
| 32 | // ����ֵ < 0 ��ʾ�Ƿ��ĵ�ַ |
| 33 | static int check_addr(const char* addr, std::string& buf, int default_count) |
| 34 | { |
| 35 | buf.clear(); |
| 36 | |
| 37 | // ���ݸ�ʽ��IP:PORT[:CONNECT_COUNT] |
| 38 | std::vector<std::string> tokens; |
| 39 | split3(addr, ":|", tokens); |
| 40 | if (tokens.size() < 2) |
| 41 | return -1; |
| 42 | |
| 43 | int port = atoi(tokens[1].c_str()); |
| 44 | if (port <= 0 || port >= 65535) |
| 45 | return -1; |
| 46 | |
| 47 | buf = tokens[0].c_str(); |
| 48 | buf += ":"; |
| 49 | buf += port; |
| 50 | |
| 51 | int conn_max; |
| 52 | if (tokens.size() >= 3) |
| 53 | conn_max = atoi(tokens[2].c_str()); |
| 54 | else |
| 55 | conn_max = default_count; |
| 56 | if (conn_max <= 0) |
| 57 | conn_max = default_count; |
| 58 | return conn_max; |
| 59 | } |
| 60 | |
| 61 | bool connect_manager::init(const char* default_addr, |
| 62 | const char* addr_list, int count) |