Can Qt WebKit detect specific network card



  • i have a specific network USB card (like USB 3G), but PC realize it like USB device. I want to send request to that device (then that device will send request to server itself). Say simply, i dont want request through network card, i'll catch request and send it to my device. How can i do? Sorrry if my question is confusing cuz my english is bad :(



  • anyone help me plz


  • Moderators

    Your OS needs to figure out the networking... Qt will just use what is configured there. My guess is that you will need to install some drivers for this to work.



  • Thanks Tobias for answer!
    My device can transfer data (file, signal) go out to network well, but OS just realize it is a USB device, i want to use webbrowser with it, i think my work is just send request to it instead of ethernet card. I researched Qtwebkit, Qnetwork (Qnetworkaccsessmanager, Qnetworkrequest . ..) but haven't found the code that written for detecting network card. My idea is replacing networkcard by my device. Can i do?


  • Moderators

    WebKit is only for rendering websites; it does not understand network cards (which are also called Network Interface Controllers -- NICs)

    You can query information about your computer's NICs using QNetworkInterface:
    @
    QList<QNetworkInterface> interfaces = QNetworkInterface::allInterfaces();
    for (int i = 0; i < interfaces.size(); ++i)
    {
    qDebug()
    << interfaces[i].hardwareAddress()
    << interfaces[i].humanReadableName();
    }
    @

    To use a non-default NIC, you need to find the QNetworkConfiguration associated with your NIC. You can list all your computer's configurations like this:
    @
    QNetworkConfigurationManager configManager;
    QList<QNetworkConfiguration> configs = configManager.allConfigurations();
    for (int i = 0; i < configs.size(); ++i)
    {
    qDebug()
    << configs[i].bearerTypeName()
    << configs[i].name();
    }
    @

    When you have found the configuration you want, make a QNetworkAccessManager use that configuration. Then, you can sent HTTP get/post requests through that NIC:
    @
    QNetworkAccessManager manager;
    manager.setConfiguration(config);

    QNetworkRequest request(...);
    QNetworkReply *reply = manager.get(request);
    @

    Read these for info on how to create a request and handle the reply:
    http://qt-project.org/doc/qt-5.0/qtnetwork/qnetworkrequest.html
    http://qt-project.org/doc/qt-5.0/qtnetwork/qnetworkreply.html
    http://qt-project.org/doc/qt-5.0/qtnetwork/qnetworkaccessmanager.html


  • Moderators

    You will need to install (or write) a driver which will tell your OS "hey, look here, this is a network card" and then all applications will be able to use it as such. This of course includes all Qt apps.



  • @JKSH, Tobias: thank you so much!!! Your methods are "my device is understood be a network card"
    But such as i asked, i want my device to tell "hey, im not network card, but i can transfer request go to internet, transfer request to me, then don't care me, myself i'll encrypt it, then send it, return reply to u after receiving and decrypt reply, c'mon baby!". Is there any way to do that?


  • Moderators

    Ah, I think understand your issue now.

    Qt depends on the Operating System (OS) to tell it which network cards are available. If the OS doesn't recognize a device as a network card, Qt won't try to treat it as a network card.

    If you want Qt to use your device as a network card, you must make your Operating System think that it's a network card. So, like Tobias said, you to get (or write) a driver for it. After that, Qt can use it to do networking stuff.

    Maybe the manufacturer already has a driver for it. What is the brand + model number of your device? Also, what is your operating system?



  • My device is made by myself and maybe call it be a mini PC, it has 1 port ethernet, 1 port USB. Thats why i dont want it to be a network card. My browser on PC will transfer/receive request/reply through my device by the way: open /dev/ttyUSB0 and read/write data from it


  • Moderators

    You are aware that there is network support available for USB? Just make your device announce that it supports that (if it is linux-based, then its setup is about as hard as using serial-over-USB) and your clients should set up a network interface as soon as it connects, pretty much like they are creating the serial port now.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.