Note that there are some explanatory texts on larger screens.

plurals
  1. POList used TCP port using C#
    primarykey
    data
    text
    <p>This is the answer to my questions.</p> <p>How to list binded/used TCP port in C#. Used modified code from <a href="https://stackoverflow.com/questions/570098/in-c-how-to-check-if-a-tcp-port-is-available/570461#570461">jro</a> </p> <pre><code> static void ListUsedTCPPort(ref ArrayList usedPort) { IPGlobalProperties ipGlobalProperties = IPGlobalProperties.GetIPGlobalProperties(); IPEndPoint[] tcpConnInfoArray = ipGlobalProperties.GetActiveTcpListeners(); IEnumerator myEnum = tcpConnInfoArray.GetEnumerator(); while (myEnum.MoveNext()) { IPEndPoint TCPInfo = (IPEndPoint)myEnum.Current; usedPort.Add(TCPInfo.Port); } } </code></pre> <p><strong>Original questions.</strong> This is how i list TCP port using C#. It is modified code i found in this forum(forgot exactly where i got it. If you are the original developer, notify me and ill put credits where due.)</p> <pre><code> //List used tcp port static void ListUsedTCPPort(ref ArrayList usedPort) { IPGlobalProperties ipGlobalProperties = IPGlobalProperties.GetIPGlobalProperties(); TcpConnectionInformation[] tcpConnInfoArray = ipGlobalProperties.GetActiveTcpConnections(); IEnumerator myEnum = tcpConnInfoArray.GetEnumerator(); while (myEnum.MoveNext()) { TcpConnectionInformation TCPInfo = (TcpConnectionInformation)myEnum.Current; usedPort.Add(TCPInfo.LocalEndPoint.Port); } } </code></pre> <p>Problem is, the results is different from used tcp port listed in TCPview(Protocol-TCP, Local port). By the way, i do know that this list used TCP port at the EXACT time its called. What did i did wrong?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload