Esempio n. 1
0
 private void StartReceiveAsync(Socket sock, SocketAsyncEventArgs readEventArgs, IncomingMessageAcceptor ima)
 {
     try
     {
         // Set up the async receive
         if (!sock.ReceiveAsync(readEventArgs))
         {
             ProcessReceive(readEventArgs);
         }
     }
     catch (Exception exception)
     {
         var socketException = exception as SocketException;
         var context         = readEventArgs.UserToken as ReceiveCallbackContext;
         ima.Log.Warn(ErrorCode.Messaging_IMA_NewBeginReceiveException,
                      $"Exception on new socket during ReceiveAsync with RemoteEndPoint " +
                      $"{socketException?.SocketErrorCode}: {context?.RemoteEndPoint}", exception);
         ima.SafeCloseSocket(sock);
         FreeSocketAsyncEventArgs(readEventArgs);
     }
 }