Exemple #1
0
int main()
{
	void *so = dlopen("tcpip.so", 0);	
	int (*entry)(int argc, char **argv);
	
	if (!so)
	{
		printf("协议栈动态库加载失败。\n");
		goto err;
	}
	
	entry = dlentry(so);
	if (!entry)
	{
		printf("Cannot get the entry address of this shared object.\n");
		goto err;
	}
	entry(0, NULL);

	/* 写包线程 */	
	if (pthread_create(&write_worker, NULL, write_thread, 0))
		goto err;
	
	/* Socket testing thread */
	//if (pthread_create(NULL, NULL, socket_thread, 0))
	//	goto err;
	
	return 0;
err:
	return -1;	
}
Exemple #2
0
int main()
{
	void *so = dlopen("tcpip.so", 0);	
	int (*entry)(int argc, char **argv);
	y_handle hevent;
	int accept_counts =0, socket_counts = 0;
	
	if (!so)
	{
		printf("协议栈动态库加载失败。\n");
		goto err;
	}
	
	entry = dlentry(so);
	if (!entry)
	{
		printf("Cannot get the entry address of this shared object.\n");
		goto err;
	}
	entry(0, NULL);
	
	/* Wait 1ms for tcpip to startup */
	hevent = y_event_create(false, false);
	y_event_wait(hevent, 1000);
	printf("OK, let's go test tcpip.\n");

	/* 写包线程 */	
	//if (pthread_create(&write_worker, NULL, write_thread, 0))
	//	goto err;

	/* test bind thread */
	if (pthread_create(NULL, NULL, accept_thread, 0))
		goto err;
	
	/* Socket testing thread */
	if (pthread_create(NULL, NULL, socket_thread, 0))
		goto err;
	
	/* We cannot exit , so wait */
	while (1)
	{
		/* 记录等待前计数 */
		accept_counts = acccept_thread_counts;
		socket_counts = socket_thread_counts;
		
		/* waits 1s */
		y_event_wait(hevent, 1000);
		printf("accept thread counts %d,socket thread counts %d.\n",
				acccept_thread_counts - accept_counts, socket_thread_counts - socket_counts);
		if ((socket_thread_counts - socket_counts) == 0)
		{
			break;
		}
			
	}
	y_event_wait(hevent, 1000000000);
	return 0;
err:
	return -1;	
}
Exemple #3
0
static void startup_services()
{
	char *argv[MAX_SERVICE_ARGC];
	int argc = 1;
	void *server;
	int (*entry)(int argc, char **argv);
//	setenv("WINEPREFIX","/0:/wine/",TRUE);
//	setenv("WINEDEBUG","+all,trace-heap",TRUE);
	printf("%s %s %d.\n", __FUNCTION__, __FILE__, __LINE__);
	server = dlopen("wineserver", RTLD_GLOBAL);
	if (!server)
		goto next;printf("%s %s %d.\n", __FUNCTION__, __FILE__, __LINE__);
	entry = dlentry(server);
	if (!entry)
		goto next;printf("%s %s %d.\n", __FUNCTION__, __FILE__, __LINE__);
	argc = 2;
	argv[0] = "wineserver";
	argv[1] = "-f";
	printf("启动Wineserver...");
	dlcall_posix_entry(entry, argc, argv);
	printf("OK.\n");
 
	return;
next:printf("%s %s %d.\n", __FUNCTION__, __FILE__, __LINE__);;
}