Tag: lan

Android通过LAN从C#桌面应用程序接收UDP广播?

我正在尝试在PC上为使用相同Wi-Fi网络的许多Android设备创建一个服务器应用程序。 设备将通过接收来自它的UDP广播找到服务器的IP,其中包含服务器IP数据。 我开始在Java中用C#和udp接收器创建一个示例udp广播器,但我从未设法在android端获取数据包。 这是代码: C#: UdpClient listener = new UdpClient(listenPort); IPEndPoint groupEP = new IPEndPoint(IPAddress.Broadcast, listenPort); listener.Connect(groupEP); listener.EnableBroadcast = true; byte[] data = new byte[1024]; try { while (!done) { Console.WriteLine(“broadcast”); Thread.Sleep(400); listener.Send(data,2); } Android代码: DatagramSocket socket; try { socket = new DatagramSocket(11000); socket.connect(getBroadcastAddress(), 11000); socket.setBroadcast(true); byte[] buf = new byte[4]; DatagramPacket packet = new […]

从LAN中的IP地址查找DNS主机名

大家好。 我编写了一个程序,可以顺序扫描局域网的某些部分以供计算机使用(将提供代码)。 但是,当我运行此代码时,它只返回正在运行的计算机的DNS HostName。 我研究过使用WMI,但我不能,因为我不会总是对所找到的计算机有所了解。 有没有其他方法可以找到本地计算机HostName? using System; using System.Net; using System.Net.NetworkInformation; using System.Text; namespace CheckLocalNetwork { class PingCheck { public static string fullip; public void CheckSequentialIP() { IPHostEntry IpEntry = Dns.GetHostEntry(fullip); Ping pingSender = new Ping(); PingOptions options = new PingOptions(); options.DontFragment = true; string data = “a”; byte[] buffer = Encoding.ASCII.GetBytes(data); int timeout […]

检查IP是否在LAN中(防火墙和路由器后面)

我现在已经在网上爬了大约5个小时,但找不到我的问题的解决方案: 我的公司正在开发一款教育游戏,我正在使用Monotorrent为它编写一个autoupdater。 该游戏将在学校中使用,但由于大多数学校只有非常弱的互联网连接,因此网络中只应有一台从httpseeder下载的计算机,而其他计算机应从从httpseed下载的一台计算机中获取。 因此,我从跟踪器获取大量IP地址,并且只需要过滤掉LAN中的IP地址。 当然,学校有时对防火墙非常严格,学校的某些计算机之间会有大量的路由器和交换机。 我已经尝试过大多数解决方案,比如 NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces(); foreach (NetworkInterface iface in interfaces) { IPInterfaceProperties properties = iface.GetIPProperties(); foreach (UnicastIPAddressInformation address in properties.UnicastAddresses) { Console.WriteLine( “{0} (Mask: {1})”, address.Address, address.IPv4Mask ); } } 或者类似的技术只提供路由器/交换机/其他信息。 简而言之,我想要做的是检查是否可以通过LAN访问给定的IP。 我真的很感激任何帮助,因为这个function是剩下的最后一个:)

从移动设备获取Lan中的所有IP主机

我希望在移动设备(C#.net紧凑框架)上获得包含网络中所有IP地址的列表。 我读了几篇像这样的文章。 问题是,在我的移动设备上我无法ping它们异步因为我只有opennetcf,它不支持它。 ping它同步需要太长时间。 你知道一个图书馆这样做或者你知道吗,我怎么能找到我网络中的所有主机,甚至可能没有ping(这很慢) 端口没关系,我只是想知道,使用了哪些IP … 谢谢你,卡尔

用于远程计算机的EventLogQuery阅读器?

我正在使用此代码从我的win7计算机上读取自己的事件日志。 EventLogQuery eventsQuery = new EventLogQuery(“Security”, PathType.LogName, queryString); eventsQuery.ReverseDirection = true; EventLogReader logReader = new EventLogReader(eventsQuery); 但是 – 我需要读取远程计算机的EventLog(Lan – Same domain) 我怎样才能做到这一点 ?

Web请求错误407需要代理身份validation

尝试从网站获取GetResponse; using System.Text; using System.Net; using System.IO; namespace DutyPharmacy751013 { class Program { static void Main(string[] args) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(“http://www.google.com/”); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Encoding encoding = Encoding.GetEncoding(response.CharacterSet); Stream stream = response.GetResponseStream(); StreamReader reader = new StreamReader(stream, encoding); string responseText= reader.ReadToEnd(); } } } 此代码适用于win7和LAN以及win8和任何无线连接,但不适用于win8和LAN错误:407需要代理身份validation。 有没有解决方案。 谢谢。

如何在c#中禁用/启用网络连接

基本上我正在运行一些性能测试,并且不希望外部网络成为阻力因素。 我正在研究禁用网络局域网的方法。 以编程方式执行此操作的有效方法是什么? 我对c#感兴趣。 如果有人有一个代码片段可以驱动点回家很酷。