Currently, using JetBrains Rider as the IDE. I am running a basic example Xamarian application template for the Mac OSX desktop. Simply by creating a new project and editing the Main.cs
only to test a simple idea.
The simple basic code added into Main.cs
is:
using System;
using System.Net.NetworkInformation;
class MainClass
{
static void Main()
{
if (!NetworkInterface.GetIsNetworkAvailable())
return;
NetworkInterface[] interfaces
= NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface ni in interfaces)
{
Console.WriteLine(" Bytes Sent: {0}",
ni.GetIPv4Statistics().BytesSent);
Console.WriteLine(" Bytes Received: {0}",
ni.GetIPv4Statistics().BytesReceived);
}
}
}
Presently, I sometimes know network traffic monitoring on interfaces requires Sudo permissions so I even opened the IDE up with Sudo permissions and it does not output any bytes incoming or out outgoing. Always, zero traffic logged.
Any ideas on network traffic monitoring in C# Mac OSX with IP address's of destination capabilities or how to allow something basic such as this to work.
Output
Bytes Sent 0
Referencing:
Documentation - Microsoft - NetworkInformation.IPv4InterfaceStats...
question from:
https://stackoverflow.com/questions/65932151/c-sharp-xamarian-net-monitoring-network-traffic-mac-osx 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…