コード例 #1
0
        static void Receive(ISearcher searcher, List <UdpClient> clients)
        {
            IPEndPoint received = new IPEndPoint(IPAddress.Parse("192.168.0.1"), 5351);

            foreach (UdpClient client in clients)
            {
                if (client.Available > 0)
                {
                    IPAddress localAddress = ((IPEndPoint)client.Client.LocalEndPoint).Address;
                    byte[]    data         = client.Receive(ref received);
                    searcher.Handle(localAddress, data, received);
                }
            }
        }
コード例 #2
0
        static async Task Receive(ISearcher searcher, List <UdpClient> clients)
        {
            foreach (UdpClient client in clients)
            {
                if (client.Available > 0)
                {
                    IPAddress localAddress = ((IPEndPoint)client.Client.LocalEndPoint).Address;
                    var       result       = await client.ReceiveAsync().ConfigureAwait(false);

                    var data     = result.Buffer;
                    var received = result.RemoteEndPoint;
                    searcher.Handle(localAddress, data, received);
                }
            }
        }
コード例 #3
0
        private static void Receive(ISearcher searcher, List <UdpClient> clients)
        {
            IPEndPoint received = new IPEndPoint(IPAddress.Parse("192.168.8.1"), 5351);

            foreach (UdpClient client in clients)
            {
#if SSHARP
                if (client.DataAvailable)
#else
                if (client.Available > 0)
#endif
                {
#if SSHARP
                    IPAddress localAddress = ((IPEndPoint)client.LocalEndPoint).Address;
#else
                    IPAddress localAddress = ((IPEndPoint)client.Client.LocalEndPoint).Address;
#endif
                    byte[] data = client.Receive(ref received);
                    searcher.Handle(localAddress, data, received);
                }
            }
        }
コード例 #4
0
ファイル: NatUtility.cs プロジェクト: t-andre/Emby
		static void Receive (ISearcher searcher, List<UdpClient> clients)
		{
			IPEndPoint received = new IPEndPoint(IPAddress.Parse("192.168.0.1"), 5351);
			foreach (UdpClient client in clients)
			{
				if (client.Available > 0)
				{
				    IPAddress localAddress = ((IPEndPoint)client.Client.LocalEndPoint).Address;
					byte[] data = client.Receive(ref received);
					searcher.Handle(localAddress, data, received);
				}
            }
        }