I'm writing an applicaiton that lists all of the ports of existing processes on the system. However the system is returning the value of 20480 as the value for port 80.
I've found a couple of articles that would indicate that the discrepancy is because of the "endianess" of the underlying system and that reversing the byte order would resolve the problem. However when I convert the return value to an array of bytes
the values show up as 0,80,0,0. Even reversing the order of the bytes wouldn't return the appropriate value of 80.
Specifically I'm calling into the iphlpapi.dll using the following function
[DllImport("iphlpapi.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
private static extern int GetExtendedTcpTable(IntPtr pTcpTable, ref int dwOutBufLen, bool bOrder, int dwFamily, TCP_TABLE_CLASS dwClass, int dwReserved);
Here's some additional code from the listing
this.m_TcpTable.Add(new TcpEntry(entry.dwState, entry.dwRemoteAddr, entry.dwRemotePort, entry.dwLocalAddr, entry.dwLocalPort, entry.dwProcessId));
public TcpEntry(TcpState state, UInt32 remoteAddr, int remotePort, UInt32 localAddress, int localPort, int processID)
this.m_State = state;
View Complete Post