Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- UniqueEventHelper.cs
- SizeAnimationUsingKeyFrames.cs
- SortKey.cs
- PrimarySelectionGlyph.cs
- Timer.cs
- NoPersistProperty.cs
- PriorityQueue.cs
- GZipDecoder.cs
- ProtocolsConfiguration.cs
- StringArrayConverter.cs
- ValidationEventArgs.cs
- ProviderCommandInfoUtils.cs
- RelationshipEndCollection.cs
- ServicesUtilities.cs
- StrongName.cs
- DetailsViewPagerRow.cs
- ParserExtension.cs
- PersonalizationAdministration.cs
- BinaryNode.cs
- RequestNavigateEventArgs.cs
- DefaultShape.cs
- OdbcRowUpdatingEvent.cs
- DrawingCollection.cs
- TraceSection.cs
- SeekStoryboard.cs
- DefaultEvaluationContext.cs
- messageonlyhwndwrapper.cs
- ReferenceSchema.cs
- BinaryReader.cs
- SecurityKeyType.cs
- SafeSecurityHandles.cs
- FrugalMap.cs
- SafeHGlobalHandleCritical.cs
- IndexOutOfRangeException.cs
- CheckBoxBaseAdapter.cs
- TargetParameterCountException.cs
- Ipv6Element.cs
- PartialCachingControl.cs
- PathData.cs
- TextParentUndoUnit.cs
- SqlWebEventProvider.cs
- SerializationObjectManager.cs
- DataMisalignedException.cs
- DataGridTextColumn.cs
- WebHeaderCollection.cs
- SqlParameterCollection.cs
- PropertyToken.cs
- ParameterCollection.cs
- InfoCardRSAOAEPKeyExchangeDeformatter.cs
- ParagraphVisual.cs
- MeasureData.cs
- FontInfo.cs
- IdnElement.cs
- NameScope.cs
- DBSchemaTable.cs
- SmiMetaDataProperty.cs
- OletxCommittableTransaction.cs
- XsltOutput.cs
- PropertyMappingExceptionEventArgs.cs
- SoapAttributeAttribute.cs
- IgnoreFileBuildProvider.cs
- ValidatingPropertiesEventArgs.cs
- SmiEventSink_DeferedProcessing.cs
- ToolboxComponentsCreatedEventArgs.cs
- CodePrimitiveExpression.cs
- documentsequencetextcontainer.cs
- Int16AnimationBase.cs
- Overlapped.cs
- CompModSwitches.cs
- GPStream.cs
- TcpClientCredentialType.cs
- PocoEntityKeyStrategy.cs
- CompilationRelaxations.cs
- WasHttpHandlersInstallComponent.cs
- ValueTypeFixupInfo.cs
- ConfigXmlElement.cs
- ProcessInputEventArgs.cs
- AdapterDictionary.cs
- PresentationAppDomainManager.cs
- OutputCacheEntry.cs
- NavigationPropertyEmitter.cs
- MeasurementDCInfo.cs
- WorkflowView.cs
- RoutedEventConverter.cs
- WebServiceTypeData.cs
- QueryStringParameter.cs
- BindingMAnagerBase.cs
- SHA1CryptoServiceProvider.cs
- XmlEntity.cs
- Assert.cs
- DesignerProperties.cs
- PointLightBase.cs
- CommonDialog.cs
- _CommandStream.cs
- ObjectStateEntry.cs
- IRCollection.cs
- PathGeometry.cs
- WebBrowserNavigatingEventHandler.cs
- ToolStripDropTargetManager.cs
- LogWriteRestartAreaState.cs