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
- DataGridViewRowConverter.cs
- SizeConverter.cs
- LogicalExpr.cs
- TabItemAutomationPeer.cs
- AdapterDictionary.cs
- CodeTypeDelegate.cs
- PropertyEmitterBase.cs
- TypeElementCollection.cs
- SchemaContext.cs
- XPathDocumentIterator.cs
- UnsettableComboBox.cs
- BindingBase.cs
- CommonGetThemePartSize.cs
- NonVisualControlAttribute.cs
- ValidationErrorCollection.cs
- GridViewUpdateEventArgs.cs
- XmlSchemaComplexType.cs
- SizeConverter.cs
- XmlQueryRuntime.cs
- InstanceDataCollection.cs
- SendKeys.cs
- PrinterUnitConvert.cs
- XmlSchemaAny.cs
- ItemDragEvent.cs
- DefaultValueTypeConverter.cs
- StylusOverProperty.cs
- ProviderConnectionPointCollection.cs
- ValidatorCollection.cs
- FeatureSupport.cs
- InProcStateClientManager.cs
- InputMethodStateTypeInfo.cs
- DataServiceQueryException.cs
- StylesEditorDialog.cs
- DayRenderEvent.cs
- UriTemplate.cs
- BuildDependencySet.cs
- RtfToXamlReader.cs
- ButtonStandardAdapter.cs
- ServiceDesigner.cs
- BaseParser.cs
- BitmapSource.cs
- unitconverter.cs
- InstanceValue.cs
- ListItemCollection.cs
- DataGridViewCellValidatingEventArgs.cs
- StartUpEventArgs.cs
- RegexCaptureCollection.cs
- ItemList.cs
- WebControlAdapter.cs
- Pool.cs
- Point3DConverter.cs
- BindingBase.cs
- NonParentingControl.cs
- DependencyPropertyDescriptor.cs
- TextBoxAutomationPeer.cs
- XmlBinaryReader.cs
- SimpleWorkerRequest.cs
- _KerberosClient.cs
- AuthenticationModulesSection.cs
- CalloutQueueItem.cs
- PeerTransportElement.cs
- RelatedImageListAttribute.cs
- GroupItemAutomationPeer.cs
- DockingAttribute.cs
- CompilerParameters.cs
- Tablet.cs
- unsafenativemethodsother.cs
- ActivityCodeDomReferenceService.cs
- RoleManagerModule.cs
- ScriptResourceAttribute.cs
- InnerItemCollectionView.cs
- BamlLocalizableResource.cs
- CommonDialog.cs
- LowerCaseStringConverter.cs
- Aes.cs
- ConstraintStruct.cs
- ScrollProperties.cs
- OdbcParameter.cs
- SpeakCompletedEventArgs.cs
- ThreadExceptionDialog.cs
- Activator.cs
- NativeMethods.cs
- TcpChannelListener.cs
- EntityModelSchemaGenerator.cs
- DecimalAnimationBase.cs
- InputScopeConverter.cs
- AppDomainFactory.cs
- MarginsConverter.cs
- DbConnectionStringCommon.cs
- HttpContext.cs
- HttpPostServerProtocol.cs
- LocalsItemDescription.cs
- mansign.cs
- ListViewAutomationPeer.cs
- HtmlElementEventArgs.cs
- TextChangedEventArgs.cs
- TimeSpanSecondsConverter.cs
- LinkAreaEditor.cs
- RelOps.cs
- hwndwrapper.cs