Skip to content

Commit

Permalink
tcp-udp count windows (debug)
Browse files Browse the repository at this point in the history
  • Loading branch information
MHSanaei committed Feb 26, 2023
1 parent 3e938de commit 23a2c54
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions util/sys/sys_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//go:build windows
// +build windows

package sys

import (
"github.com/shirou/gopsutil/v3/net"
)

func GetTCPCount() (int, error) {
stats, err := net.Connections("tcp")
if err != nil {
return 0, err
}
return len(stats), nil
}

func GetUDPCount() (int, error) {
stats, err := net.Connections("udp")
if err != nil {
return 0, err
}
return len(stats), nil
}

0 comments on commit 23a2c54

Please sign in to comment.