D
D
Dima_E2020-08-04 00:03:56
Python
Dima_E, 2020-08-04 00:03:56

How to find out through Python which ports are occupied by applications in Windows?

What library can provide such functionality? (Which ports applications use)
Needed to collect information for the subsequent separation of traffic through the router.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
Hemul GM, 2020-08-04
@Dima_E

On Windows? If yes, then use WinAPI to access this information.
Dig in this direction. Namespaces: Windows, Winsock, Winsock2.

GetTcpTable: function(pTcpTable: PMIB_TCPTABLE; var pdwSize: DWORD; bOrder: BOOL): DWORD; stdcall; 
{$EXTERNALSYM GetTcpTable}
GetUdpTable: function(pUdpTable: PMIB_UDPTABLE; var pdwSize: DWORD; bOrder: BOOL): DWORD; stdcall;
{$EXTERNALSYM GetUdpTable}


GetExtendedTcpTable: function(pTcpTable: PMIB_TCPEXTABLE; var pdwSize: DWORD; bOrder: BOOL; ulAf: ULONG; TableClass: TCP_TABLE_CLASS; Reserved: ULONG): DWORD; stdcall;
{$EXTERNALSYM GetExtendedTcpTable}
GetExtendedUdpTable: function(pTcpTable: PMIB_UDPEXTABLE; var pdwSize: DWORD; bOrder: BOOL; ulAf: ULONG; TableClass: UDP_TABLE_CLASS; Reserved: ULONG): DWORD; stdcall;
{$EXTERNALSYM GetExtendedUdpTable}

These WinApi methods allow you to get information about open ports and the processes for which they are open
. This is how it looks:
5f28e791916dc732699772.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question