Files
bl/common/utils/tcpping.go
2026-01-23 14:59:15 +00:00

21 lines
271 B
Go

package utils
import (
"net"
"time"
)
func TcpPing(address string) (n int64, err error) {
s := time.Now()
tcpConn, err := net.Dial("tcp", address)
n = time.Now().Sub(s).Milliseconds()
if n == 0 {
n = 1
}
if err != nil {
return
}
tcpConn.Close()
return
}