Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

MIB_TCPROW_OWNER_PID (Structures)
 
.
Summary
The MIB_TCPROW_OWNER_PID structure contains information that describes an IPv4 TCP connection with IPv4 addresses, ports used by the TCP connection, and the specific process ID (PID) associated with connection.

C# Definition:

[StructLayout(LayoutKind.Sequential)]
public struct MIB_TCPROW_OWNER_PID
{
    public uint state;
    public uint localAddr;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
    public byte[] localPort;
    public uint remoteAddr;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
    public byte[] remotePort;
    public uint owningPid;

    public uint ProcessId
    {
        get { return owningPid; }
    }

    public IPAddress LocalAddress
    {
        get { return new IPAddress(localAddr); }
    }

    public ushort LocalPort
    {
        get
        {
            return BitConverter.ToUInt16(new byte[2] { localPort[1], localPort[0] }, 0);
        }
    }

    public IPAddress RemoteAddress
    {
        get { return new IPAddress(remoteAddr); }
    }

    public ushort RemotePort
    {
        get
        {
            return BitConverter.ToUInt16( new byte[2] { remotePort[1], remotePort[0] }, 0);
        }
    }

    public MIB_TCP_STATE State
    {
        get { return (MIB_TCP_STATE)state; }
    }
}

VB Definition:

<StructLayout(LayoutKind.Sequential)> _
Public Structure MIB_TCPROW_OWNER_PID
    Public m_state As UInteger
    Public localAddr As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst := 4)> _
    Public m_localPort As Byte()
    Public remoteAddr As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst := 4)> _
    Public m_remotePort As Byte()
    Public owningPid As UInteger

    Public ReadOnly Property ProcessId() As UInteger
        Get
            Return owningPid
        End Get
    End Property

    Public ReadOnly Property LocalAddress() As IPAddress
        Get
            Return New IPAddress(localAddr)
        End Get
    End Property

    Public ReadOnly Property LocalPort() As UShort
        Get
            Return BitConverter.ToUInt16(New Byte(1) {m_localPort(1), m_localPort(0)}, 0)
        End Get
    End Property

    Public ReadOnly Property RemoteAddress() As IPAddress
        Get
            Return New IPAddress(remoteAddr)
        End Get
    End Property

    Public ReadOnly Property RemotePort() As UShort
        Get
            Return BitConverter.ToUInt16(New Byte(1) {m_remotePort(1), m_remotePort(0)}, 0)
        End Get
    End Property

    Public ReadOnly Property State() As MIB_TCP_STATE
        Get
            Return DirectCast(m_state, MIB_TCP_STATE)
        End Get
    End Property
End Structure

User-Defined Field Types:

MIB_TCP_STATE

Notes:

This table entry is specifically returned by a call to GetExtendedTcpTable with the TableClass parameter set to a TCP_TABLE_OWNER_PID_* value from the TCP_TABLE_CLASS enumeration and the ulAf parameter set to AF_INET4.

Ports are broken up by bytes. (This is the same as the standard library does it). High order by is returned first.   Port 139 would be represented as  localPort1 =0, localPort2=139, localPort3=0, localPort4=0, where as 5800 would be localPort1=22, localPort2=168, etc...,   MSDN shows these as being DWORD.

Documentation

Please edit this page!

Do you have...

  • helpful tips?
  • corrections to the existing content?
  • alternate definitions?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing any supporting types needed.

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions