Esempio n. 1
0
 private static void ReceiveCallback(IAsyncResult ar)
 {
     if (receive)
     {
         try
         {
             UdpClient  _client       = (UdpClient)ar.AsyncState;
             IPEndPoint ipEndpoint    = new IPEndPoint(IPAddress.Any, 0);
             byte[]     connectBuffer = _client.EndReceive(ar, ref ipEndpoint);
             HandleDataUDP.HandleNetworkInformation(CheckIP(ipEndpoint), connectBuffer);
             if (receive)
             {
                 _client.BeginReceive(new AsyncCallback(ReceiveCallback), _client);
             }
         }
         catch (SocketException e)
         {
             //try
             //{
             //    connectUDP.BeginReceive(new AsyncCallback(ReceiveCallback), connectUDP);
             //    Global.serverForm.Debug("Flawless victory");
             //}
             //catch
             //{
             Global.serverForm.Debug(e + "");
             //}
         }
     }
 }
Esempio n. 2
0
 public static void WaitConnect()
 {
     HandleDataUDP.InitializeNetworkPackages();
     try
     {
         connectUDP = new UdpClient(Constants.UDP_PORT);
         buffer     = new byte[Constants.UDP_BUFFER_SIZE];
         receive    = true;
         connectUDP.BeginReceive(new AsyncCallback(ReceiveCallback), connectUDP);
         Global.serverForm.StatusIndicator(2);
     }
     catch (SocketException ex)
     {
         Global.serverForm.StatusIndicator(2, ex);
     }
 }