1 Star 1 Fork 15

lihuaib/sbalance

forked from hotmocha/sbalance 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
sbparsehost.h 1.62 KB
一键复制 编辑 原始数据 按行查看 历史
hotmocha 提交于 2015-06-10 19:41 . a
#ifndef _SBPARSE_H_
#define _SBPARSE_H_
#include <stdio.h>
#include <unistd.h>
#include <ares.h>
#include "sbalance.h"
#include "sblist.h"
#define SB_DNS_MAX_IP_LEN 65
#define SB_DNS_STATUS_DESTORYED -1 /* not in wait or parse list and channel destoryed */
#define SB_DNS_STATUS_INITED 0 /* temp status, not in wait or parse list after inited */
#define SB_DNS_STATUS_WAITING 1 /* int wait list*/
#define SB_DNS_STATUS_PARSING 2 /* in parse list */
#define SB_DNS_STATUS_OK 3 /* parse ok, notice not in wait or parse and channel destoryed */
#define SB_DNS_STATUS_TIMEOUT 4 /* temp status */
#define SB_DNS_STATUS_ERROR 5 /* temp status */
struct sb_dns
{
char host[SB_DNS_MAX_HOSTNAME_LEN];
char ip[SB_DNS_MAX_IP_LEN]; /* only save one ip address */
int status; /* 0:inited 1: parsing 2: done 3: timeout*/
ares_channel channel;
unsigned long timeout_time;
struct list_head list_node;
struct hlist_node hash_node;
/* the waiting for dns this request */
struct list_head waiting_session_list;
};
int sb_dns_init_env();
/****
1. SB_OK(hit host's ip)
2. SB_AGAIN(a. not find host's ip, but add query request, b. find host, but the status is parsing)
3. SB_TIMEOUT(find host, but the status is timeout) temp status, not possible status
4. SB_ERROR
****/
int sb_dns_query_host_ip(const char *host, struct sb_session *sess);
int sb_dns_modify_status(char *host, int new_status);
void sb_dns_remove_session(struct sb_session *sess);
int sb_dns_process();
void sb_dns_set_done_handler(struct sb_session *sess, void (*handler)(void*, int, int, struct hostent*) );
int sb_dns_reparse_host(struct sb_dns *dns, struct sb_session *sess);
#endif
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lihuaib/sbalance.git
git@gitee.com:lihuaib/sbalance.git
lihuaib
sbalance
sbalance
master

搜索帮助