Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / Net / System / Net / Sockets / _ConnectOverlappedAsyncResult.cs / 1 / _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
- DbConnectionPoolCounters.cs
- SecurityTokenSpecification.cs
- XmlNode.cs
- ExtendedProtectionPolicyElement.cs
- SystemIPInterfaceProperties.cs
- EntityDataSourceStatementEditor.cs
- SocketStream.cs
- CollectionDataContractAttribute.cs
- GatewayIPAddressInformationCollection.cs
- PrinterUnitConvert.cs
- ContentIterators.cs
- ClickablePoint.cs
- QueryParameter.cs
- Debugger.cs
- CharacterShapingProperties.cs
- InstanceDescriptor.cs
- User.cs
- BigInt.cs
- BindingObserver.cs
- LayoutTableCell.cs
- ExpressionNormalizer.cs
- precedingquery.cs
- UnionCqlBlock.cs
- Content.cs
- ExtensionSimplifierMarkupObject.cs
- XmlQueryRuntime.cs
- ComponentResourceManager.cs
- BaseDataListActionList.cs
- Highlights.cs
- RtfControls.cs
- TaskHelper.cs
- CompareInfo.cs
- ComEventsHelper.cs
- UnmanagedMarshal.cs
- SettingsPropertyWrongTypeException.cs
- ProfileEventArgs.cs
- SatelliteContractVersionAttribute.cs
- TouchDevice.cs
- CheckBoxPopupAdapter.cs
- BlurEffect.cs
- GroupDescription.cs
- NameValueSectionHandler.cs
- DrawingAttributesDefaultValueFactory.cs
- SafeNativeMethods.cs
- Base64Stream.cs
- HierarchicalDataSourceConverter.cs
- Shape.cs
- ThemeableAttribute.cs
- StaticTextPointer.cs
- SessionStateItemCollection.cs
- TaskDesigner.cs
- SmiMetaDataProperty.cs
- AppSecurityManager.cs
- SourceFilter.cs
- ParsedAttributeCollection.cs
- StylusPointPropertyInfo.cs
- AudioStateChangedEventArgs.cs
- ListBoxItemAutomationPeer.cs
- DataServiceSaveChangesEventArgs.cs
- _LocalDataStore.cs
- AsyncOperationManager.cs
- ReflectionHelper.cs
- IteratorFilter.cs
- CustomUserNameSecurityTokenAuthenticator.cs
- ValidationError.cs
- WindowsImpersonationContext.cs
- ReadOnlyDataSourceView.cs
- SystemEvents.cs
- SerialPinChanges.cs
- MILUtilities.cs
- ControlBuilder.cs
- StateManagedCollection.cs
- CryptoConfig.cs
- TextTreePropertyUndoUnit.cs
- DomNameTable.cs
- COM2DataTypeToManagedDataTypeConverter.cs
- LifetimeServices.cs
- ContainerParaClient.cs
- XamlReaderConstants.cs
- SimpleNameService.cs
- UriWriter.cs
- RSAOAEPKeyExchangeFormatter.cs
- FtpWebRequest.cs
- ObjectDataSource.cs
- InProcStateClientManager.cs
- ScriptResourceInfo.cs
- StorageComplexTypeMapping.cs
- SqlMethods.cs
- ColorMatrix.cs
- ResXFileRef.cs
- Console.cs
- PageSettings.cs
- CodeCatchClause.cs
- ResourceDescriptionAttribute.cs
- ListItemViewControl.cs
- UIElementIsland.cs
- Hash.cs
- coordinatorfactory.cs
- ISAPIRuntime.cs
- GPRECT.cs