Esempio n. 1
0
func (p *InstancePortTable) nextPort(host net.IP, from port.Port) port.HostPort {
	key := port.HostPort{host.String(), 0}
	for port := from; ; port++ {
		key.Port = port
		if _, ok := p.reserved[key]; !ok {
			p.reserved[key] = true
			return key
		}
		if port > 65535 {
			port = 40000
		}
	}
	panic("Unable to locate a valid port")
}