mirror of
https://github.com/AlchemillaHQ/Sylve.git
synced 2026-06-26 02:45:10 +03:00
18 lines
259 B
Go
18 lines
259 B
Go
package network
|
|
|
|
import (
|
|
"fmt"
|
|
"net"
|
|
)
|
|
|
|
func TryBindToPort(ip string, port int, proto string) error {
|
|
addr := fmt.Sprintf("%s:%d", ip, port)
|
|
listener, err := net.Listen(proto, addr)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
defer listener.Close()
|
|
return nil
|
|
}
|