Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Net / System / Net / Sockets / _ConnectOverlappedAsyncResult.cs / 1305376 / _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
- URLIdentityPermission.cs
- LinkLabel.cs
- UpdateTranslator.cs
- ColorTranslator.cs
- xmlglyphRunInfo.cs
- TextHidden.cs
- PropertyMappingExceptionEventArgs.cs
- PasswordTextNavigator.cs
- CallTemplateAction.cs
- MergeExecutor.cs
- UnicodeEncoding.cs
- TextParentUndoUnit.cs
- DataSourceExpressionCollection.cs
- EdmItemCollection.OcAssemblyCache.cs
- ChildDocumentBlock.cs
- CaretElement.cs
- HitTestParameters3D.cs
- FusionWrap.cs
- XmlText.cs
- StylusPointPropertyInfoDefaults.cs
- Model3D.cs
- DynamicUpdateCommand.cs
- NativeMethodsCLR.cs
- documentsequencetextcontainer.cs
- DropDownList.cs
- SchemaNamespaceManager.cs
- DataGridViewImageColumn.cs
- OrderedDictionary.cs
- BitmapEffectInput.cs
- FigureParagraph.cs
- CssTextWriter.cs
- SqlNotificationEventArgs.cs
- ProcessHostFactoryHelper.cs
- EntityException.cs
- SecurityTokenValidationException.cs
- ExpressionBuilderContext.cs
- SerializationHelper.cs
- FilterQuery.cs
- ILGenerator.cs
- RegexRunner.cs
- Button.cs
- AppendHelper.cs
- SQLInt32.cs
- SimpleHandlerFactory.cs
- IncrementalReadDecoders.cs
- Track.cs
- XamlRtfConverter.cs
- DrawingDrawingContext.cs
- WebMessageEncodingElement.cs
- BidPrivateBase.cs
- DataGridViewRowCancelEventArgs.cs
- Exception.cs
- Debug.cs
- FileDialog_Vista.cs
- MimeObjectFactory.cs
- SecurityDescriptor.cs
- TextOptions.cs
- TransportBindingElement.cs
- LocalizableAttribute.cs
- ViewSimplifier.cs
- MaterialCollection.cs
- MaterialCollection.cs
- XmlnsDictionary.cs
- PasswordDeriveBytes.cs
- ConnectionPointConverter.cs
- ProfileSettingsCollection.cs
- MultiByteCodec.cs
- Evaluator.cs
- IntegerFacetDescriptionElement.cs
- Function.cs
- TextAnchor.cs
- Literal.cs
- PolygonHotSpot.cs
- CommunicationObjectAbortedException.cs
- KernelTypeValidation.cs
- Stylesheet.cs
- SchemaElementDecl.cs
- OleDbDataReader.cs
- SqlCaseSimplifier.cs
- TemplateFactory.cs
- SelectionProcessor.cs
- ConfigurationSectionGroup.cs
- ColumnHeaderConverter.cs
- GridLengthConverter.cs
- ExpressionBuilderContext.cs
- XPathAxisIterator.cs
- HttpCookieCollection.cs
- ProxyRpc.cs
- OleDbConnectionInternal.cs
- DetailsViewUpdatedEventArgs.cs
- ReversePositionQuery.cs
- InitializerFacet.cs
- DetailsViewUpdateEventArgs.cs
- ACE.cs
- ObjectStateEntryDbUpdatableDataRecord.cs
- SchemaRegistration.cs
- ClientCredentialsSecurityTokenManager.cs
- DbDataRecord.cs
- SpecialNameAttribute.cs
- MailWebEventProvider.cs