Example #1
0
void acl_end(void)
{
	static int __have_ended = 0;

	if (__have_ended)
		return;
	__have_ended = 1;
#if  defined(WIN32)
	acl_socket_end();
	acl_pthread_end();
#endif
}
Example #2
0
void acl_lib_end(void)
{
	static int __have_ended = 0;

	if (__have_ended)
		return;
	__have_ended = 1;
#if  defined(ACL_WINDOWS)
	acl_socket_end();
	acl_pthread_end();
#endif
}
Example #3
0
File: main.c Project: 10jschen/acl
int main(int argc, char* argv[])
{
	char  ch;
	int   npkt = 5, i, syn = 0, thread = 0;
	ACL_ARGV* dest_list = acl_argv_alloc(10);

	signal(SIGINT, OnSigInt);  /* 用户按下 ctr + c 时中断 PING 程序 */
	acl_socket_init();  /* 在 WIN32 下需要初始化全局套接字库 */
	acl_msg_stdout_enable(1);  /* 允许 acl_msg_xxx 记录的信息输出至屏幕 */

	while ((ch = getopt(argc, argv, "htsl:n:")) > 0) {
		switch (ch) {
		case 'h':
			usage(argv[0]);
			return (0);
		case 's':
			syn = 1;
			break;
		case 't':
			thread = 1;
			break;
		case 'n':
			npkt = atoi(optarg);
			break;
		default:
			usage(argv[0]);
			return (0);
		}
	}

	if (optind == argc) {
		usage(argv[0]);
		return (0);
	}

	for (i = optind; i < argc; i++) {
		acl_argv_add(dest_list, argv[i], NULL);
	}

	if (npkt <= 0)
		npkt = 0;

	/* 同步 PING 方式,对于多个目标地址,采用一个线程 PING 一个地址 */
	if (thread)
		ping_main_threads(dest_list, npkt);

	/* 同步 PING 方式,只能同时 PING 一个地址 */
	else if (syn)
		ping_main_sync(dest_list->argv[0], npkt);

	/* 异步 PING 方式,可以在一个线程中同时 PING 多个地址 */
	else
		ping_main_async(dest_list, npkt);

	acl_argv_free(dest_list);

#ifdef WIN32
	printf("please enter any key to exit\r\n");
	getchar();
#endif

	acl_socket_end();
	return 0;
}