isPortFree returns true if port is free (no TCP connection possible).
(port string)
| 254 | |
| 255 | // isPortFree returns true if port is free (no TCP connection possible). |
| 256 | func isPortFree(port string) bool { |
| 257 | addr := net.JoinHostPort("127.0.0.1", port) |
| 258 | conn, err := net.DialTimeout("tcp", addr, 250*time.Millisecond) |
| 259 | if err != nil { |
| 260 | return true |
| 261 | } |
| 262 | |
| 263 | conn.Close() |
| 264 | // Dial succeeded -> something is listening -> not free. |
| 265 | return false |
| 266 | } |
| 267 | |
| 268 | func runConnectedMode(ctx context.Context, cli *cli, projectDir, port string, screensToWatch []string) error { |
| 269 | fmt.Println("\n🚀 " + ansi.Green("ACUL connected dev mode started for: "+ansi.Cyan(projectDir))) |
no test coverage detected