private async void NewClient(Socket socket, int millisecondsDelay)
 {
     try
     {
         socket.Connect(address);
         OnConnect?.Invoke(this, new EventArgs());
     }
     catch (Exception exception)
     {
         OnConnectException?.Invoke(this, new ExceptionEventArgs(socket, exception));
     }
     while (true)
     {
         try
         {
             socket.Send(messageBuffer);
             OnSend?.Invoke(this, new EventArgs());
         }
         catch (Exception exception)
         {
             OnSendException?.Invoke(this, new ExceptionEventArgs(socket, exception));
         }
         await Task.Delay(millisecondsDelay);
     }
 }
Exemple #2
0
 private void Connecting <M>(IPAddress ipAddress, int port, bool useExceptionList)
 {
     try
     {
         Socket.Connect(ipAddress, port);
         IsWorking = true;
         OnConnect?.Invoke(this, new EventArgs());
         ListenServer <M>();
     }
     catch (Exception exception)
     {
         if (useExceptionList)
         {
             CheckException(exception);
         }
         else
         {
             OnConnectException?.Invoke(this, new ExceptionEventArgs(Socket, exception));
         }
     }
 }