示例#1
0
文件: Server.cpp 项目: athomaj/Babel
void    Server::select_manage()
{
  while (42)
    {
      setFds();
      if (select(maxFd + 1, &fdRead, &fdWrite, NULL, NULL) == -1)
        throw ("select failed\n");
      checkFds();
        usleep(100000);
    }
}
示例#2
0
文件: ServerW.cpp 项目: Frootzy/Babel
void	ServerW::launch()
{
	std::cout << "ServerW running on port 4242\nWaiting for clients..." << std::endl;
	while (1)
	{
		setFds();
		if (select(_fdMax + 1, &_fdRead, &_fdWrite, NULL, NULL) == -1)
			throw(std::exception("Select failed"));
		checkFds();
	}
}
示例#3
0
文件: AClient.cpp 项目: athomaj/RType
void AClient::run(std::string const& ip, int const port)
{
    _sIn.sin_family = AF_INET;
    _sIn.sin_port = htons(port);
    _sIn.sin_addr.s_addr = inet_addr(ip.c_str());
    socket();
    if (_clientType == TCP)
        connect();

    while (42)
    {
        resetFds();
        setFds();
        select();
        checkFds();
    }
}