Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / Net / System / Net / Sockets / _ConnectOverlappedAsyncResult.cs / 5 / _ConnectOverlappedAsyncResult.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Net.Sockets {
using System;
using System.Net;
using System.Runtime.InteropServices;
using System.Threading;
using Microsoft.Win32;
//
// ConnectOverlappedAsyncResult - used to take care of storage for async Socket BeginAccept call.
//
internal class ConnectOverlappedAsyncResult : BaseOverlappedAsyncResult {
private EndPoint m_EndPoint;
internal ConnectOverlappedAsyncResult(Socket socket, EndPoint endPoint, Object asyncState, AsyncCallback asyncCallback):
base(socket,asyncState,asyncCallback)
{
m_EndPoint = endPoint;
}
//
// This method is called by base.CompletionPortCallback base.OverlappedCallback as part of IO completion
//
internal override object PostCompletion(int numBytes) {
SocketError errorCode = (SocketError)ErrorCode;
Socket socket = (Socket)AsyncObject;
if (errorCode==SocketError.Success) {
//set the socket context
try
{
errorCode = UnsafeNclNativeMethods.OSSOCK.setsockopt(
socket.SafeHandle,
SocketOptionLevel.Socket,
SocketOptionName.UpdateConnectContext,
null,
0);
if (errorCode == SocketError.SocketError) errorCode = (SocketError) Marshal.GetLastWin32Error();
}
catch (ObjectDisposedException)
{
errorCode = SocketError.OperationAborted;
}
ErrorCode = (int) errorCode;
}
if (errorCode==SocketError.Success) {
socket.SetToConnected();
return socket;
}
return null;
}
internal EndPoint RemoteEndPoint {
get { return m_EndPoint; }
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Net.Sockets {
using System;
using System.Net;
using System.Runtime.InteropServices;
using System.Threading;
using Microsoft.Win32;
//
// ConnectOverlappedAsyncResult - used to take care of storage for async Socket BeginAccept call.
//
internal class ConnectOverlappedAsyncResult : BaseOverlappedAsyncResult {
private EndPoint m_EndPoint;
internal ConnectOverlappedAsyncResult(Socket socket, EndPoint endPoint, Object asyncState, AsyncCallback asyncCallback):
base(socket,asyncState,asyncCallback)
{
m_EndPoint = endPoint;
}
//
// This method is called by base.CompletionPortCallback base.OverlappedCallback as part of IO completion
//
internal override object PostCompletion(int numBytes) {
SocketError errorCode = (SocketError)ErrorCode;
Socket socket = (Socket)AsyncObject;
if (errorCode==SocketError.Success) {
//set the socket context
try
{
errorCode = UnsafeNclNativeMethods.OSSOCK.setsockopt(
socket.SafeHandle,
SocketOptionLevel.Socket,
SocketOptionName.UpdateConnectContext,
null,
0);
if (errorCode == SocketError.SocketError) errorCode = (SocketError) Marshal.GetLastWin32Error();
}
catch (ObjectDisposedException)
{
errorCode = SocketError.OperationAborted;
}
ErrorCode = (int) errorCode;
}
if (errorCode==SocketError.Success) {
socket.SetToConnected();
return socket;
}
return null;
}
internal EndPoint RemoteEndPoint {
get { return m_EndPoint; }
}
}
}
// 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
- SqlFormatter.cs
- BlockExpression.cs
- PhoneCall.cs
- XmlAnyAttributeAttribute.cs
- HttpCookieCollection.cs
- String.cs
- RemotingConfigParser.cs
- WasAdminWrapper.cs
- IPPacketInformation.cs
- QuaternionConverter.cs
- EncodingDataItem.cs
- DecodeHelper.cs
- ExpandedWrapper.cs
- DataBoundControlAdapter.cs
- ContextMenuStripActionList.cs
- PolyQuadraticBezierSegment.cs
- BitmapFrameEncode.cs
- AmbiguousMatchException.cs
- ScriptingProfileServiceSection.cs
- SafeHandle.cs
- ExitEventArgs.cs
- EventEntry.cs
- Dump.cs
- MatrixCamera.cs
- _AutoWebProxyScriptWrapper.cs
- DBPropSet.cs
- AppDomainShutdownMonitor.cs
- DispatchChannelSink.cs
- DataColumnChangeEvent.cs
- SiteMapNodeItem.cs
- EncryptedKey.cs
- DependencyPropertyHelper.cs
- ByteKeyFrameCollection.cs
- AssemblyBuilder.cs
- RSAOAEPKeyExchangeFormatter.cs
- CodeDomComponentSerializationService.cs
- BatchServiceHost.cs
- Vector3dCollection.cs
- SmtpReplyReader.cs
- KeyboardNavigation.cs
- ApplicationHost.cs
- PropertyPathWorker.cs
- Vector3D.cs
- FtpWebResponse.cs
- DefaultPropertyAttribute.cs
- MachineKeySection.cs
- SchemaTableColumn.cs
- FileUpload.cs
- NativeMethods.cs
- WebPartHelpVerb.cs
- TextContainerChangeEventArgs.cs
- Script.cs
- TextMetrics.cs
- CollectionEditVerbManager.cs
- ClientConfigurationSystem.cs
- FixedSOMSemanticBox.cs
- BamlWriter.cs
- CustomGrammar.cs
- WindowsTreeView.cs
- Material.cs
- SerializationEventsCache.cs
- MetadataCache.cs
- ScriptResourceAttribute.cs
- CurrentChangingEventArgs.cs
- BaseDataListPage.cs
- RegionInfo.cs
- ChannelServices.cs
- TimeStampChecker.cs
- PersianCalendar.cs
- RemoteCryptoDecryptRequest.cs
- WebPartEditorApplyVerb.cs
- SymLanguageType.cs
- HttpCacheVaryByContentEncodings.cs
- TrackingQueryElement.cs
- WindowsPen.cs
- EnumerableRowCollection.cs
- ComNativeDescriptor.cs
- SystemIPv6InterfaceProperties.cs
- TdsValueSetter.cs
- XXXOnTypeBuilderInstantiation.cs
- WebInvokeAttribute.cs
- ApplicationInfo.cs
- PartialArray.cs
- ObjectPersistData.cs
- FullTrustAssembliesSection.cs
- DataGridViewHitTestInfo.cs
- DrawingBrush.cs
- Identity.cs
- AuthenticationConfig.cs
- Listbox.cs
- invalidudtexception.cs
- AnimationTimeline.cs
- ObjectStateEntryBaseUpdatableDataRecord.cs
- FileCodeGroup.cs
- MultiAsyncResult.cs
- DataSourceHelper.cs
- RunInstallerAttribute.cs
- DataSetMappper.cs
- Sentence.cs
- BinaryParser.cs