MCPcopy Create free account
hub / github.com/bytesizedhosting/bcd / PortFree

Function PortFree

core/helpers.go:70–82  ·  view source on GitHub ↗
(port string)

Source from the content-addressed store, hash-verified

68}
69
70func PortFree(port string) bool {
71 log.Debugf("Checking if port %s is free", port)
72
73 conn, err := net.Dial("tcp", "127.0.0.1:"+port)
74 if err != nil {
75 log.Debugf("Port is free: %s", err.Error())
76 return true
77 } else {
78 log.Debugf("Port already in use")
79 conn.Close()
80 return false
81 }
82}
83
84func EnsurePath(pathName string) error {
85 log.Debugf("Ensuring folder %s exists.", pathName)

Callers 1

GetFreePortFunction · 0.85

Calls 1

CloseMethod · 0.80

Tested by

no test coverage detected