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

  1. //------------------------------------------------------------------------------
  2. // <copyright file="SocketException.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.ComponentModel;
  19.     using System.Runtime.Serialization;
  20.     using System.Runtime.InteropServices;
  21.    
  22.     /// <devdoc>
  23.     /// <para>
  24.     /// Provides socket exceptions to the application.
  25.     /// </para>
  26.     /// </devdoc>
  27.     [Serializable()]
  28.     public class SocketException : Win32Exception
  29.     {
  30.         /// <devdoc>
  31.         /// <para>
  32.         /// Creates a new instance of the <see cref='System.Net.Sockets.SocketException'/> class with the default error code.
  33.         /// </para>
  34.         /// </devdoc>
  35.         public SocketException() : base(Marshal.GetLastWin32Error())
  36.         {
  37.             GlobalLog.Print("SocketException::.ctor() " + NativeErrorCode.ToString() + ":" + Message);
  38.         }
  39.        
  40.         /// <devdoc>
  41.         /// <para>
  42.         /// Creates a new instance of the <see cref='System.Net.Sockets.SocketException'/> class with the specified error code.
  43.         /// </para>
  44.         /// </devdoc>
  45.         public SocketException(int errorCode) : base(errorCode)
  46.         {
  47.             GlobalLog.Print("SocketException::.ctor(int) " + NativeErrorCode.ToString() + ":" + Message);
  48.         }
  49.        
  50.         /// <devdoc>
  51.         /// <para>
  52.         /// Creates a new instance of the <see cref='System.Net.Sockets.SocketException'/> class with the specified error code as SocketError.
  53.         /// </para>
  54.         /// </devdoc>
  55.         internal SocketException(SocketError socketError) : base((int)socketError)
  56.         {
  57.         }
  58.        
  59.         protected SocketException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext)
  60.         {
  61.             GlobalLog.Print("SocketException::.ctor(serialized) " + NativeErrorCode.ToString() + ":" + Message);
  62.         }
  63.        
  64.         /// <devdoc>
  65.         /// <para>[To be supplied.]</para>
  66.         /// </devdoc>
  67.         public override int ErrorCode {
  68.             //
  69.             // the base class returns the HResult with this property
  70.             // we need the Win32 Error Code, hence the override.
  71.             //
  72.             get { return NativeErrorCode; }
  73.         }
  74.        
  75.         public SocketError SocketErrorCode {
  76.             //
  77.             // the base class returns the HResult with this property
  78.             // we need the Win32 Error Code, hence the override.
  79.             //
  80.             get { return (SocketError)NativeErrorCode; }
  81.         }
  82.        
  83.        
  84.     }
  85.     // class SocketException
  86.    
  87. }
  88. // namespace System.Net

Developer Fusion