Skip to content
This repository was archived by the owner on Jul 9, 2023. It is now read-only.

Commit 5e8daf5

Browse files
committed
make the line shorter (and cast only once :) )
1 parent 3f66d38 commit 5e8daf5

File tree

1 file changed

+6
-6
lines changed
  • Titanium.Web.Proxy/Helpers

1 file changed

+6
-6
lines changed

Titanium.Web.Proxy/Helpers/Tcp.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ internal static TcpTable GetExtendedTcpTable(IpVersion ipVersion)
3030
int tcpTableLength = 0;
3131

3232
int ipVersionValue = ipVersion == IpVersion.Ipv4 ? NativeMethods.AfInet : NativeMethods.AfInet6;
33+
int allPid = (int)NativeMethods.TcpTableType.OwnerPidAll;
3334

34-
if (NativeMethods.GetExtendedTcpTable(tcpTable, ref tcpTableLength, false, ipVersionValue, (int)NativeMethods.TcpTableType.OwnerPidAll, 0) != 0)
35+
if (NativeMethods.GetExtendedTcpTable(tcpTable, ref tcpTableLength, false, ipVersionValue, allPid, 0) != 0)
3536
{
3637
try
3738
{
3839
tcpTable = Marshal.AllocHGlobal(tcpTableLength);
39-
if (NativeMethods.GetExtendedTcpTable(tcpTable, ref tcpTableLength, true, ipVersionValue, (int)NativeMethods.TcpTableType.OwnerPidAll, 0) ==
40-
0)
40+
if (NativeMethods.GetExtendedTcpTable(tcpTable, ref tcpTableLength, true, ipVersionValue, allPid, 0) == 0)
4141
{
4242
var table = (NativeMethods.TcpTable)Marshal.PtrToStructure(tcpTable, typeof(NativeMethods.TcpTable));
4343

@@ -72,14 +72,14 @@ internal static TcpRow GetTcpRowByLocalPort(IpVersion ipVersion, int localPort)
7272
int tcpTableLength = 0;
7373

7474
int ipVersionValue = ipVersion == IpVersion.Ipv4 ? NativeMethods.AfInet : NativeMethods.AfInet6;
75+
int allPid = (int)NativeMethods.TcpTableType.OwnerPidAll;
7576

76-
if (NativeMethods.GetExtendedTcpTable(tcpTable, ref tcpTableLength, false, ipVersionValue, (int)NativeMethods.TcpTableType.OwnerPidAll, 0) != 0)
77+
if (NativeMethods.GetExtendedTcpTable(tcpTable, ref tcpTableLength, false, ipVersionValue, allPid, 0) != 0)
7778
{
7879
try
7980
{
8081
tcpTable = Marshal.AllocHGlobal(tcpTableLength);
81-
if (NativeMethods.GetExtendedTcpTable(tcpTable, ref tcpTableLength, true, ipVersionValue, (int)NativeMethods.TcpTableType.OwnerPidAll, 0) ==
82-
0)
82+
if (NativeMethods.GetExtendedTcpTable(tcpTable, ref tcpTableLength, true, ipVersionValue, allPid, 0) == 0)
8383
{
8484
var table = (NativeMethods.TcpTable)Marshal.PtrToStructure(tcpTable, typeof(NativeMethods.TcpTable));
8585

0 commit comments

Comments
 (0)