Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Net / System / Net / NetworkInformation / SystemTcpConnection.cs / 1305376 / SystemTcpConnection.cs
namespace System.Net.NetworkInformation { using System.Net; using System.Net.Sockets; using System.Security.Permissions; using System; using System.Runtime.InteropServices; using System.Collections; using System.ComponentModel; using System.Threading; ////// Represents an active Tcp connection. internal class SystemTcpConnectionInformation:TcpConnectionInformation { IPEndPoint localEndPoint; IPEndPoint remoteEndPoint; TcpState state; internal SystemTcpConnectionInformation(MibTcpRow row) { state = row.state; //port is returned in Big-Endian - most significant bit on left //unfortunately, its done at the word level and not the dword level. int localPort = row.localPort1<<8|row.localPort2; int remotePort = ((state == TcpState.Listen)?0:row.remotePort1<<8|row.remotePort2); localEndPoint = new IPEndPoint(row.localAddr,(int)localPort); remoteEndPoint= new IPEndPoint(row.remoteAddr,(int)remotePort); } // IPV6 version of the Tcp row internal SystemTcpConnectionInformation(MibTcp6RowOwnerPid row) { state = row.state; //port is returned in Big-Endian - most significant bit on left //unfortunately, its done at the word level and not the dword level. int localPort = row.localPort1 << 8 | row.localPort2; int remotePort = ((state == TcpState.Listen) ? 0 : row.remotePort1 << 8 | row.remotePort2); localEndPoint = new IPEndPoint(new IPAddress(row.localAddr, row.localScopeId), (int)localPort); remoteEndPoint = new IPEndPoint(new IPAddress(row.remoteAddr, row.remoteScopeId), (int)remotePort); } public override TcpState State{get {return state;}} public override IPEndPoint LocalEndPoint{get {return localEndPoint;}} public override IPEndPoint RemoteEndPoint{get {return remoteEndPoint;}} } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. namespace System.Net.NetworkInformation { using System.Net; using System.Net.Sockets; using System.Security.Permissions; using System; using System.Runtime.InteropServices; using System.Collections; using System.ComponentModel; using System.Threading; ////// Represents an active Tcp connection. internal class SystemTcpConnectionInformation:TcpConnectionInformation { IPEndPoint localEndPoint; IPEndPoint remoteEndPoint; TcpState state; internal SystemTcpConnectionInformation(MibTcpRow row) { state = row.state; //port is returned in Big-Endian - most significant bit on left //unfortunately, its done at the word level and not the dword level. int localPort = row.localPort1<<8|row.localPort2; int remotePort = ((state == TcpState.Listen)?0:row.remotePort1<<8|row.remotePort2); localEndPoint = new IPEndPoint(row.localAddr,(int)localPort); remoteEndPoint= new IPEndPoint(row.remoteAddr,(int)remotePort); } // IPV6 version of the Tcp row internal SystemTcpConnectionInformation(MibTcp6RowOwnerPid row) { state = row.state; //port is returned in Big-Endian - most significant bit on left //unfortunately, its done at the word level and not the dword level. int localPort = row.localPort1 << 8 | row.localPort2; int remotePort = ((state == TcpState.Listen) ? 0 : row.remotePort1 << 8 | row.remotePort2); localEndPoint = new IPEndPoint(new IPAddress(row.localAddr, row.localScopeId), (int)localPort); remoteEndPoint = new IPEndPoint(new IPAddress(row.remoteAddr, row.remoteScopeId), (int)remotePort); } public override TcpState State{get {return state;}} public override IPEndPoint LocalEndPoint{get {return localEndPoint;}} public override IPEndPoint RemoteEndPoint{get {return remoteEndPoint;}} } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ConfigsHelper.cs
- BindingManagerDataErrorEventArgs.cs
- ActiveXHelper.cs
- CodeCommentStatement.cs
- DependencyObjectProvider.cs
- FrameSecurityDescriptor.cs
- SqlComparer.cs
- ViewEvent.cs
- KeyValueInternalCollection.cs
- PropertyFilterAttribute.cs
- SqlBulkCopyColumnMapping.cs
- VerificationAttribute.cs
- GZipStream.cs
- SpeakCompletedEventArgs.cs
- ZipPackagePart.cs
- FocusTracker.cs
- OdbcInfoMessageEvent.cs
- DockAndAnchorLayout.cs
- _ConnectionGroup.cs
- SmiGettersStream.cs
- FacetValues.cs
- SamlAdvice.cs
- InkCanvas.cs
- WinEventTracker.cs
- PersonalizationStateInfo.cs
- PolyLineSegment.cs
- RootDesignerSerializerAttribute.cs
- TracingConnection.cs
- ServiceProviders.cs
- RSAPKCS1SignatureFormatter.cs
- ShaperBuffers.cs
- IndicCharClassifier.cs
- SimpleWebHandlerParser.cs
- IgnorePropertiesAttribute.cs
- SvcMapFileLoader.cs
- ToolStrip.cs
- CommandPlan.cs
- GB18030Encoding.cs
- SerializerProvider.cs
- SystemIPInterfaceStatistics.cs
- ValidationSummary.cs
- UdpSocketReceiveManager.cs
- X509UI.cs
- PrivacyNoticeBindingElementImporter.cs
- PrintController.cs
- Constants.cs
- PipelineModuleStepContainer.cs
- HostedHttpTransportManager.cs
- ChannelReliableSession.cs
- KerberosSecurityTokenAuthenticator.cs
- DbgCompiler.cs
- ComponentResourceManager.cs
- SafeThreadHandle.cs
- ByteStack.cs
- XmlSyndicationContent.cs
- XmlSchemaExporter.cs
- References.cs
- HashJoinQueryOperatorEnumerator.cs
- ConfigurationManagerHelper.cs
- OAVariantLib.cs
- GeneralTransform3DTo2D.cs
- SapiGrammar.cs
- SafeEventLogReadHandle.cs
- KnownTypes.cs
- Int32CollectionValueSerializer.cs
- DispatchWrapper.cs
- SqlDataSourceQuery.cs
- StatusCommandUI.cs
- XsltCompileContext.cs
- BitStack.cs
- ElementNotEnabledException.cs
- XmlDeclaration.cs
- DbRetry.cs
- SchemaConstraints.cs
- CacheOutputQuery.cs
- RelOps.cs
- Help.cs
- Timeline.cs
- EntityDataSourceMemberPath.cs
- RegexWorker.cs
- IResourceProvider.cs
- ChannelServices.cs
- SecurityTokenException.cs
- DataGridViewSelectedCellCollection.cs
- FormViewPageEventArgs.cs
- SparseMemoryStream.cs
- CodeFieldReferenceExpression.cs
- MsmqInputChannelListener.cs
- DataTableExtensions.cs
- QuadraticBezierSegment.cs
- PartitionedDataSource.cs
- BaseAddressElementCollection.cs
- DataGridParentRows.cs
- XmlChildEnumerator.cs
- DesignerLoader.cs
- NameValuePermission.cs
- AuthenticationModulesSection.cs
- SrgsRule.cs
- WebPartVerb.cs
- EntityDataSourceContainerNameItem.cs