How is it possible to get the Socket ID (Handle) of the created sockets of a program?

I know I can get all the open sockets in all programs by GetTcpTable() but it has two problems:

  1. It shows all programs sockets
  2. It doesn't return ID (Handle) of sockets
Edit
Report