Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Net / System / Net / SocketException.cs / 2 / 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
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ConfigXmlElement.cs
- ISFClipboardData.cs
- MemberBinding.cs
- ExpandedWrapper.cs
- StorageInfo.cs
- _WebProxyDataBuilder.cs
- BitmapData.cs
- RequestCacheEntry.cs
- SafeViewOfFileHandle.cs
- SqlHelper.cs
- DaylightTime.cs
- SqlFormatter.cs
- DecimalAnimationUsingKeyFrames.cs
- CodePropertyReferenceExpression.cs
- QueryCacheKey.cs
- FacetChecker.cs
- IdentityNotMappedException.cs
- EntitySqlQueryBuilder.cs
- Triangle.cs
- SerializationInfoEnumerator.cs
- HttpWebResponse.cs
- figurelengthconverter.cs
- ContextMenuService.cs
- _SecureChannel.cs
- PoisonMessageException.cs
- DefaultSerializationProviderAttribute.cs
- EdmItemCollection.OcAssemblyCache.cs
- ProcessModule.cs
- Convert.cs
- NavigatorOutput.cs
- SQLDoubleStorage.cs
- TrackBarRenderer.cs
- TagPrefixCollection.cs
- XmlStreamStore.cs
- ImpersonateTokenRef.cs
- ScriptResourceInfo.cs
- UserPreferenceChangingEventArgs.cs
- SafeCryptoKeyHandle.cs
- XmlReaderSettings.cs
- PassportAuthenticationEventArgs.cs
- InstanceDataCollection.cs
- ParameterRefs.cs
- listitem.cs
- SoapElementAttribute.cs
- DispatcherEventArgs.cs
- TypeDependencyAttribute.cs
- TreeNodeStyleCollection.cs
- SelectingProviderEventArgs.cs
- X509AsymmetricSecurityKey.cs
- XmlFormatExtensionAttribute.cs
- FontUnitConverter.cs
- OleDbStruct.cs
- DefaultClaimSet.cs
- DataTemplateSelector.cs
- BitmapInitialize.cs
- StyleConverter.cs
- _LocalDataStoreMgr.cs
- BamlResourceContent.cs
- ConnectionStringsSection.cs
- ConstructorExpr.cs
- NetTcpBindingCollectionElement.cs
- ResourcePermissionBase.cs
- _BaseOverlappedAsyncResult.cs
- HasCopySemanticsAttribute.cs
- BinaryParser.cs
- ExceptionUtil.cs
- CanExecuteRoutedEventArgs.cs
- ConfigUtil.cs
- Deserializer.cs
- MouseOverProperty.cs
- GeometryConverter.cs
- FileStream.cs
- DoubleCollectionConverter.cs
- ButtonField.cs
- ProcessModule.cs
- _OverlappedAsyncResult.cs
- ZipPackagePart.cs
- TemplateComponentConnector.cs
- CompressedStack.cs
- SQLMoney.cs
- WindowsMenu.cs
- HasActivatableWorkflowEvent.cs
- ConfigurationValue.cs
- TemplateContent.cs
- Rectangle.cs
- XmlCharCheckingReader.cs
- SwitchDesigner.xaml.cs
- StreamMarshaler.cs
- ImportOptions.cs
- DynamicQueryableWrapper.cs
- CfgSemanticTag.cs
- ComponentResourceManager.cs
- Misc.cs
- Token.cs
- XmlCharacterData.cs
- DateTimeFormat.cs
- JsonFaultDetail.cs
- unsafeIndexingFilterStream.cs
- Listbox.cs
- RemotingServices.cs