Example #1
0
int main()
{
	int listenfd = TcpServer("127.0.0.1", 8976);
	epoll_t et;
	epoll_init(&et, listenfd, &run);


	while(1)
	{	
		epoll_loop(&et);	
		epoll_handle_fd(&et);
	}
	//epoll_destroy(&et);
	close(et.epoll_fd_);
	close(listenfd);	
}
Example #2
0
int main(void)
{
	//
	std::string filepath = "/home/chao/Desktop/project/spellcorrect/conf/my.conf";
	MyConf myconf(filepath);
	myconf.init();
	myconf.show();

	std::map<std::string, std::string> my_map = myconf.get_map();
	std::string sip = my_map["server_ip"];
	std::string sport = my_map["server_port"];
	std::stringstream ss(sport);
	int iport = 0;
	ss >> iport;
	std::cout << iport << std::endl;

	ThreadPool thp(50, 10);
	thp.start();



	InetAddress inetAddr(sip, iport);
	Socket mySocket;
	mySocket.init(0, inetAddr);

	int listenfd = mySocket.get_sockfd();

	epoll_t et;
	epoll_init(&et, listenfd, &foo );
	while(1)
	{
		epoll_loop(&et);
		epoll_handle_fd(&et, thp);

	}

	epoll_destroy(&et);

	return 0;
}