示例#1
0
	/*! Check to see if there are any waiting inbound connections on any of the managed servers. Will only
		return the first ServerSession; select should be called continually to process all waiting sockets.
	  \param timeout timespan (us, default 250 ms) to wait before returning (will return immediately if connection available)
	  \return pointer to ServerSession that is ready to accept a connection or nullptr if timeout with none */
	ServerSessionBase *select(const Poco::Timespan& timeout=Poco::Timespan(250000)) const
	{
		Poco::Net::Socket::SocketList readList, writeList, exceptList;
		for (auto& pp : _servermap)
			readList.push_back(pp.first);
		return Poco::Net::Socket::select(readList, writeList, exceptList, timeout) && !readList.empty()
			? _servermap.find(readList[0])->second : nullptr;
	}
示例#2
0
	/*! Check to see if there are any waiting inbound connections on any of the managed servers. Will add
		all ServerSession pointers to the supplied vector for all waiting sockets found.
	  \param result vector to place results in; will empty before polling
	  \param timeout timespan (us, default 250 ms) to wait before returning (will return immediately if connection available)
	  \return number of active ServerSockets returned in vector */
	size_t select_l(std::vector<ServerSessionBase *>& result, const Poco::Timespan& timeout=Poco::Timespan(250000)) const
	{
		result.clear();
		Poco::Net::Socket::SocketList readList, writeList, exceptList;
		for (auto& pp : _servermap)
			readList.push_back(pp.first);
		if (Poco::Net::Socket::select(readList, writeList, exceptList, timeout) && !readList.empty())
			std::for_each(readList.begin(), readList.end(), [&](decltype(readList)::value_type& pp)
				{ result.push_back(_servermap.find(pp)->second); });
		return result.size();
	}