Exemple #1
0
 public void Dispose()
 {
     if (ClientSocket != null)
     {
         ClientSocket.StopListeningAsync().Wait();
         ClientSocket.Dispose();
         ClientSocket = null;
     }
 }
Exemple #2
0
        private async Task SendDiscoveryPacketAsync()
        {
            var ports = Network.GetAvailablePort(1000, Networks.Count);

            if (ports.Count == 0 || ports.Count < Networks.Count)
            {
                HelperMy.Notification(Color.Red, "Kullanılabilir port bulunamadığı için işlem iptal edildi.");
                await ClientSocket.StopListeningAsync();

                ClientSocket.Dispose();
                ClientSocket = null;
                return;
            }
            for (int i = 0; i < Networks.Count; i++)
            {
                var item = Networks[i];
                var data = PacketGenerator.GenerateDiscoveryPacket(item.LocalIPAddress, (short)ports[i]);
                await ClientSocket.SendToAsync(data, new IPEndPoint(item.BroadcastIPAddress, 80));
            }
        }