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
- HttpHandlerActionCollection.cs
- ItemType.cs
- DrawTreeNodeEventArgs.cs
- TreeChangeInfo.cs
- InstalledFontCollection.cs
- ProcessManager.cs
- DPAPIProtectedConfigurationProvider.cs
- COM2Enum.cs
- SourceFilter.cs
- SchemaName.cs
- WebPartManagerInternals.cs
- CollectionChangeEventArgs.cs
- AssemblyCache.cs
- CaseKeyBox.xaml.cs
- StringWriter.cs
- XmlSchemaSimpleTypeUnion.cs
- PackageRelationship.cs
- AffineTransform3D.cs
- WindowsListBox.cs
- Geometry.cs
- MarshalDirectiveException.cs
- PageVisual.cs
- Rect.cs
- EndOfStreamException.cs
- MulticastIPAddressInformationCollection.cs
- xmlglyphRunInfo.cs
- PaperSource.cs
- TextBox.cs
- VersionPair.cs
- StorageConditionPropertyMapping.cs
- RemoteX509Token.cs
- FileLogRecordStream.cs
- NameValuePermission.cs
- ChangeProcessor.cs
- WebEvents.cs
- TextSelectionHighlightLayer.cs
- ServiceDeploymentInfo.cs
- SBCSCodePageEncoding.cs
- WinFormsUtils.cs
- VoiceChangeEventArgs.cs
- TextParentUndoUnit.cs
- HtmlSelect.cs
- Image.cs
- DbRetry.cs
- TCEAdapterGenerator.cs
- ShapeTypeface.cs
- StorageComplexPropertyMapping.cs
- FixUp.cs
- BaseWebProxyFinder.cs
- XPathNodeIterator.cs
- ConfigurationException.cs
- TableColumn.cs
- XslException.cs
- BCLDebug.cs
- WeakReadOnlyCollection.cs
- NavigationWindow.cs
- ActionFrame.cs
- GroupBoxDesigner.cs
- DrawingVisual.cs
- DelegateArgumentValue.cs
- ObjectQueryState.cs
- VisualStyleTypesAndProperties.cs
- AnimationTimeline.cs
- ReachBasicContext.cs
- SQLInt32Storage.cs
- DataGridViewCheckBoxColumn.cs
- regiisutil.cs
- XmlSerializerSection.cs
- SizeConverter.cs
- BasicHttpSecurity.cs
- Win32Native.cs
- ExpressionConverter.cs
- RijndaelManaged.cs
- GifBitmapEncoder.cs
- FocusWithinProperty.cs
- ConstNode.cs
- CultureTableRecord.cs
- MatrixTransform.cs
- LayoutDump.cs
- SettingsPropertyValueCollection.cs
- XmlEncoding.cs
- ImageKeyConverter.cs
- QuaternionAnimation.cs
- SplitterPanelDesigner.cs
- Screen.cs
- WebPartCollection.cs
- HScrollBar.cs
- SslStream.cs
- Evidence.cs
- ExpressionVisitor.cs
- ProcessModelInfo.cs
- ConfigurationPropertyCollection.cs
- AttachedPropertyBrowsableAttribute.cs
- ZoneIdentityPermission.cs
- ArcSegment.cs
- FileDialogCustomPlace.cs
- PathFigure.cs
- arclist.cs
- CompilationUtil.cs
- HandlerBase.cs