コード例 #1
0
ファイル: main.cpp プロジェクト: cintiaf/LittleThumb
int		main(int ac, char **av)
{
	(void)ac;
	(void)av;
	IClient	*co = NULL;
	HandleConnection hc;


#ifdef _WIN32
	co = new Connection_Win();
	std::cout << "* Running in Windows env *" << std::endl;
#else
	co = new Connection_Lin();
	std::cout << "* Running in UNIX env *" << std::endl;
#endif
	if (co->connection(atoi(av[1]), IPS) == true)
		std::cout << "Worked" << std::endl;
	else
		std::cout << "blop" << std::endl;

	// PortAudio 	audio(co);
	// audio.initialize();
	// audio.initInputDevice();
	// audio.openRecordStream();
	// audio.initOutputDevice();
	// audio.openPlayStream();
	// audio.recordSound();
	// audio.playSound();
	hc.handle(co);
	//co->connectionHost(atoi(av[1]), IP);
	//co->handle_connection();
	//std::cout << "not good" << std::endl;
	//while (1);
	// if (ac == 2)
	//   {
	//     if (co->connection(atoi(av[1]), IP) == true)
	//       std::cout << "Worked" << std::endl;
	//     else
	//       {
	// 	std::cout << "blop" << std::endl;
	// 	return (1);
	//       }
	//     b = co;
	//     // co->create_server(atoi(av[1]));
	//     //std::cout << "not good" << std::endl;
	//     std::cout << "aeza" << std::endl;
	//     std::thread th1 (init_server);
	//     std::thread th2 (init_server);
	//     std::cout << "azeaze" << std::endl;
	//     th1.join();
	//     th2.join();
	//     //std::thread th2 (init_server);
	//     // while (1)
	//     //   {
	//     // 	read(0, buff, 500);
	//     // 	std::string b(buff);
	//     // 	co->write_to_server(b);
	//     //   }
	//   }
}
コード例 #2
0
int main()
{
    IClient *client = new Client("127.0.0.1", 12321);
    std::string msg = "Hello world !";

    if (client->connection(AF_INET, SOCK_STREAM, "TCP") == 0) {
        client->sendMessage(msg.c_str(), msg.size());

        client->disconnection();
    }

    delete client;

    return 0;
}