The Labs \ Source Viewer \ SSCLI \ System.Net.Sockets \ DisconnectOverlappedAsyncResult

  1. //------------------------------------------------------------------------------
  2. // <copyright file="_AcceptOverlappedAsyncResult.cs" company="Microsoft">
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. // </copyright>
  14. //------------------------------------------------------------------------------
  15. namespace System.Net.Sockets
  16. {
  17.     using System;
  18.     using System.Net;
  19.     using System.Runtime.InteropServices;
  20.     using System.Threading;
  21.     using Microsoft.Win32;
  22.    
  23.     //
  24.     // DisconnectOverlappedAsyncResult - used to take care of storage for async Socket BeginAccept call.
  25.     //
  26.     internal class DisconnectOverlappedAsyncResult : BaseOverlappedAsyncResult
  27.     {
  28.        
  29.        
  30.         internal DisconnectOverlappedAsyncResult(Socket socket, object asyncState, AsyncCallback asyncCallback) : base(socket, asyncState, asyncCallback)
  31.         {
  32.         }
  33.        
  34.         //
  35.         // This method will be called by us when the IO completes synchronously and
  36.         // by the ThreadPool when the IO completes asynchronously. (only called on WinNT)
  37.         //
  38.        
  39.         internal override object PostCompletion(int numBytes)
  40.         {
  41.             if (ErrorCode == (int)SocketError.Success) {
  42.                 Socket socket = (Socket)AsyncObject;
  43.                 socket.SetToDisconnected();
  44.                 socket.m_RemoteEndPoint = null;
  45.             }
  46.             return base.PostCompletion(numBytes);
  47.         }
  48.     }
  49. }

Developer Fusion