linux环境下 c++ 检查网络连接状态api



using namespace std;
 
bool checkNet()
{

    try{


        vector v;
        std::array buffer;

        std::unique_ptr pipe(popen("ping www.baidu.com -c 2 -w 2 ", "r"), pclose);


        if (!pipe) {
            throw std::runtime_error("popen() failed!");
        }
        while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) {
            std::cout<<"qqq: "< 1)
    {
        string data = v[v.size()-2];
        std::cout<<"1qqq data: "<

你可能感兴趣的:(c++,python,c++,检查网络连接状态,linux环境下)