Exemple #1
0
	std::string getHostAddresses()
	{
		std::string result;
		Poco::Net::NetworkInterface::NetworkInterfaceList list = Poco::Net::NetworkInterface::list();
		for (Poco::Net::NetworkInterface::NetworkInterfaceList::iterator it = list.begin(); it != list.end(); ++it)
		{
			const Poco::Net::IPAddress& addr = it->address();
			if (addr.isUnicast() && !addr.isLoopback())
			{
				if (!result.empty())
					result += ", ";
				result += addr.toString();
			}
		}
		return result;
	}
Exemple #2
0
 shared::CDataContainer CSystem::getNetworkInterfaces(bool includeLoopback)
 {
    try
    {
       shared::CDataContainer result;
       Poco::Net::NetworkInterface::NetworkInterfaceList netlist = Poco::Net::NetworkInterface::list();
       for (Poco::Net::NetworkInterface::NetworkInterfaceList::iterator nit = netlist.begin(); nit != netlist.end(); ++nit)
       {
          if (includeLoopback || nit->address().isLoopback())
             result.set(nit->name(), (boost::format("%1% (%2%)") % nit->displayName() % nit->address().toString()).str(), 0x00); //in case of key contains a dot, just ensure the full key is taken into account
       }
       return CResult::GenerateSuccess(result);
    }
    catch (std::exception &ex)
    {
       return CResult::GenerateError(ex);
    }
    catch (...)
    {
       return CResult::GenerateError("unknown exception in retreiving all serial ports");
    }
 }