// GetFreeAddresses asks the kernel for free open ports that are ready to use
GetFreeAddresses asks the kernel for free open ports that are ready to use
// GetFreeAddresses asks the kernel for free open ports that are ready to use
func GetFreeAddresses(count int) ([]string, error) {
	ports := make([]string, 0)
	for i := 0; i < count; i++ {
		addr, err := net.ResolveTCPAddr("tcp", localhost+"0")
		if err != nil {
			return nil, err
		}
		l, err := net.ListenTCP("tcp", addr)
		if err != nil {
			return nil, err
		}
		defer l.Close()
		ports = append(ports, localhost+strconv.Itoa(l.Addr().(*net.TCPAddr).Port))
	}
	return ports, nil
}
func GetFreeAddresses ( count int ) ( [ ] string , error ) { ports := make ( [ ] string , 0 ) for i := 0 ; i < count ; i ++ { addr , err := net . ResolveTCPAddr ( " " , localhost + " " ) if err != nil { return nil , err } l , err := net . ListenTCP ( " " , addr ) if err != nil { return nil , err } defer l . Close ( ) ports = append ( ports , localhost + strconv . Itoa ( l . Addr ( ) . ( * net . TCPAddr ) . Port ) ) } return ports , nil }
GetFreeAddresses asks the kernel for free open ports that are ready to use
GetFreeAddresses asks the kernel for free open ports that are ready to use