GithubHelp home page GithubHelp logo

qt-widgets / qping Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jaytwolab/qping

1.0 1.0 0.0 50 KB

Ping class for Qt

Home Page: https://j2doll.github.io/QPing/

License: MIT License

C++ 83.23% QMake 16.77%

qping's Introduction

QPing

Read this in other languages: English, ๐Ÿ‡ฐ๐Ÿ‡ท ํ•œ๊ตญ์–ด

  • Ping class for Qt 5

  • You can check the response by shooting the ping.

Note

  • I do not call functions that use the ICMP protocol.
    • I have written a raw socket program for pinging in the past.
    • But there's a problem with user's elevation. Application should be executed by root or superuser.

How to use

  • Copy QPing.h, QPing.cpp to your project.

  • Append Qt project(*.pro) setting of source code

HEADERS += QPing.h
SOURCES += QPing.cpp
  • Add source code that applies the class. See main.cpp.
// main.cpp 
#include "QPing.h"

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    QString destIpAddress = "192.168.0.1";
    if ( argc == 2 )
    {
        // You can use application first parameter
        // For example) QPingSF 192.168.100.10
        QString strArg = argv[1];
        destIpAddress = strArg;
    }

    // See sample of *.ini for each OS and language. You can make your own INI.
    QString iniFilePath = "./ping-config-win-en.ini"; // Windows, English
    // QString iniFilePath = "./ping-config-win-kr.ini"; // Windows, Korean
    // QString iniFilePath = "./ping-config-linux-en.ini"; // Linux, English

    QPing qp;
     
    qp.setIniFile( iniFilePath ); // set configuration file
    if ( ! qp.loadIniFile() )
    {
        std::cout <<  "[ERROR] Failed to load ini file" << std::endl;
        return (-1);
    }

    // Ping!
    QPing::pingResult result = qp.ping(destIpAddress);

    switch( result )
    {
        case QPing::pingSuccess:
            std::cout <<  "Success to ping" << std::endl;
        break;

        case QPing::pingFailed:
            std::cout <<  "Failed to ping" << std::endl;
        break;

        case QPing::initFailed: // something wrong
            std::cout <<  "[ERROR] Initialization is failed" << std::endl;
        break;

        case QPing::notFound: // something wrong
            std::cout <<  "[ERROR] Result is not found" << std::endl;
        break;
    }

    return 0;  // return a.exec();
}

License and links

Contact

qping's People

Contributors

j2doll avatar shujaatak avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.