Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Net / System / Net / SocketException.cs / 1305376 / SocketException.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Net.Sockets {
using System;
using System.ComponentModel;
using System.Runtime.Serialization;
using System.Runtime.InteropServices;
///
///
/// Provides socket exceptions to the application.
///
///
[Serializable]
public class SocketException : Win32Exception {
[NonSerialized]
private EndPoint m_EndPoint;
///
///
/// Creates a new instance of the class with the default error code.
///
///
public SocketException() : base(Marshal.GetLastWin32Error()) {
GlobalLog.Print("SocketException::.ctor() " + NativeErrorCode.ToString() + ":" + Message);
}
internal SocketException(EndPoint endPoint) : base(Marshal.GetLastWin32Error()) {
m_EndPoint = endPoint;
}
///
///
/// Creates a new instance of the class with the specified error code.
///
///
public SocketException(int errorCode) : base(errorCode) {
GlobalLog.Print("SocketException::.ctor(int) " + NativeErrorCode.ToString() + ":" + Message);
}
internal SocketException(int errorCode, EndPoint endPoint) : base(errorCode) {
m_EndPoint = endPoint;
}
///
///
/// Creates a new instance of the class with the specified error code as SocketError.
///
///
internal SocketException(SocketError socketError) : base((int)socketError) {
}
protected SocketException(SerializationInfo serializationInfo, StreamingContext streamingContext)
: base(serializationInfo, streamingContext) {
GlobalLog.Print("SocketException::.ctor(serialized) " + NativeErrorCode.ToString() + ":" + Message);
}
///
/// [To be supplied.]
///
public override int ErrorCode {
//
// the base class returns the HResult with this property
// we need the Win32 Error Code, hence the override.
//
get {
return NativeErrorCode;
}
}
public override string Message {
get {
// If not null add EndPoint.ToString() to end of base Message
if (m_EndPoint == null) {
return base.Message;
} else {
return base.Message + " " + m_EndPoint.ToString();
}
}
}
public SocketError SocketErrorCode {
//
// the base class returns the HResult with this property
// we need the Win32 Error Code, hence the override.
//
get {
return (SocketError)NativeErrorCode;
}
}
}; // class SocketException
} // namespace System.Net
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- AuthenticationException.cs
- PreloadedPackages.cs
- SeparatorAutomationPeer.cs
- FlatButtonAppearance.cs
- ScrollData.cs
- NaturalLanguageHyphenator.cs
- TypeCacheManager.cs
- GrammarBuilderWildcard.cs
- SecurityDescriptor.cs
- StrokeCollectionDefaultValueFactory.cs
- TransactionFilter.cs
- ComNativeDescriptor.cs
- EncryptedPackage.cs
- TransformGroup.cs
- EventLogPermissionEntryCollection.cs
- GenerateTemporaryTargetAssembly.cs
- HttpWebRequest.cs
- SHA512Managed.cs
- XPathNavigatorKeyComparer.cs
- CodeTypeParameter.cs
- XmlNamespaceDeclarationsAttribute.cs
- CodeAttributeDeclarationCollection.cs
- IIS7UserPrincipal.cs
- ConfigurationException.cs
- cookie.cs
- TrustSection.cs
- EntityDataSourceChangedEventArgs.cs
- EntityClassGenerator.cs
- PseudoWebRequest.cs
- DesignerVerb.cs
- XmlWrappingReader.cs
- RegexStringValidatorAttribute.cs
- UIElementHelper.cs
- AsymmetricKeyExchangeDeformatter.cs
- CompensationDesigner.cs
- UxThemeWrapper.cs
- Margins.cs
- TypeSystem.cs
- AspNetHostingPermission.cs
- CapabilitiesUse.cs
- ProtectedConfiguration.cs
- AddInBase.cs
- DataErrorValidationRule.cs
- Pens.cs
- InternalTypeHelper.cs
- SplayTreeNode.cs
- SocketException.cs
- SourceCollection.cs
- HTTPRemotingHandler.cs
- SecurityAppliedMessage.cs
- TableHeaderCell.cs
- SerializerDescriptor.cs
- XPathParser.cs
- MouseEvent.cs
- AnnotationResourceCollection.cs
- DataGridViewCheckBoxColumn.cs
- DecoderBestFitFallback.cs
- HashHelper.cs
- EdmToObjectNamespaceMap.cs
- FormattedText.cs
- DebuggerAttributes.cs
- TextOptions.cs
- AspCompat.cs
- AssemblyBuilder.cs
- NextPreviousPagerField.cs
- GlyphInfoList.cs
- SaveFileDialog.cs
- PropertyGeneratedEventArgs.cs
- MenuItemAutomationPeer.cs
- NotifyIcon.cs
- RegistryPermission.cs
- wgx_render.cs
- HttpWriter.cs
- MessageFormatterConverter.cs
- RolePrincipal.cs
- HttpInputStream.cs
- sortedlist.cs
- DataGridViewRowHeightInfoPushedEventArgs.cs
- Run.cs
- MSAAWinEventWrap.cs
- TTSVoice.cs
- WCFBuildProvider.cs
- AssemblyAttributesGoHere.cs
- XmlSchemaException.cs
- BaseParaClient.cs
- HitTestParameters.cs
- ParallelQuery.cs
- Msec.cs
- SectionUpdates.cs
- UserControlBuildProvider.cs
- SamlAssertionKeyIdentifierClause.cs
- ReadOnlyHierarchicalDataSourceView.cs
- WeakReference.cs
- StylusPointPropertyId.cs
- RealProxy.cs
- CompilerParameters.cs
- BitmapEncoder.cs
- RequestBringIntoViewEventArgs.cs
- InputChannelAcceptor.cs
- RC2CryptoServiceProvider.cs