C#获得网络连接信息 IPGlobalProperties

本文介绍如何使用C#的IPGlobalProperties类获取本地计算机的网络连接信息,包括IPv4的统计数据,如接收、转发、投递和丢弃的数据包数量。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原文: C#获得网络连接信息 IPGlobalProperties

IPGlobalProperties 提供有关本地计算机的网络连接的信息。

此类提供有关本地计算机的网络接口和网络连接的配置和统计信息 可以获取本机TCP UDP 丢包 发包等数据。

此类提供的信息与 IP Helper API 函数提供的信息相似。有关 IP Helper 的信息,请参见 MSDN Library 中的文档。

1             //得到本机Internet协议IPV4的统计数据;
2             IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties();
3             IPGlobalStatistics ipstat = properties.GetIPv4GlobalStatistics();
4             Console.WriteLine("  Inbound Packet Data:");
5             Console.WriteLine("      Received ............................ : {0}",ipstat.ReceivedPackets);
6             Console.WriteLine("      Forwarded ........................... : {0}",ipstat.ReceivedPacketsForwarded);
7             Console.WriteLine("      Delivered ........................... : {0}",ipstat.ReceivedPacketsDelivered);
8             Console.WriteLine("      Discarded ........................... : {0}",ipstat.ReceivedPacketsDiscarded);   

 

 

https://msdn.microsoft.com/zh-cn/library/system.net.networkinformation.ipglobalproperties%28v=vs.110%29.aspx

posted on 2019-05-16 23:51 NET未来之路 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/lonelyxmas/p/10878850.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值