首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Qt中的应用网络流量监控

Qt中的应用网络流量监控
EN

Stack Overflow用户
提问于 2013-09-10 14:15:30
回答 1查看 1.9K关注 0票数 2

我已经搜索了一段时间了,但是是否有一种方法可以使用已经内置到Qt库中的设备来监视特定应用程序中的网络流量呢?我已经找到了一些使用WinPCap和其他类似实用程序的解决方案,但我希望将其保存在Qt ( C++)中,因为这是我最熟悉的。

谢谢!任何指点都是非常感谢的!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-10 14:31:43

c#嗅探器套接字创建的一些示例。

代码语言:javascript
复制
    mainSocket = new Socket(AddressFamily.InterNetwork, SocketType.Raw,
                           ProtocolType.IP);

    // Bind the socket to the selected IP address
    mainSocket.Bind(newIPEndPoint(IPAddress.Parse(cmbInterfaces.Text),0));

    // Set the socket options
    mainSocket.SetSocketOption(SocketOptionLevel.IP,  //Applies only to IP packets
                               SocketOptionName.HeaderIncluded, //Set the include header
                               true);                           //option to true

    byte[] byTrue = newbyte[4]{1, 0, 0, 0};
    byte[] byOut = newbyte[4];

    //Socket.IOControl is analogous to the WSAIoctl method of Winsock 2
    mainSocket.IOControl(IOControlCode.ReceiveAll,  //SIO_RCVALL of Winsock
                         byTrue, byOut);

    //Start receiving the packets asynchronously
    mainSocket.BeginReceive(byteData, 0, byteData.Length, SocketFlags.None,
                            newAsyncCallback(OnReceive), null);

也许qt提供了一些api来创建这样的sockets.After,创建这样的套接字,您将在上面得到原始的pacets,解析头和其他信息。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18721348

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档