tmp=new DatagramSocket(localPort, bind_addr); // first time localPort is 0
if(num_last_ports <= 0)
break;
localPort=tmp.getLocalPort();
if(last_ports_used == null)
last_ports_used=new BoundedList(num_last_ports);
if(last_ports_used.contains(new Integer(localPort))) {
if(log.isDebugEnabled())
log.debug("local port " + localPort + " already seen in this session; will try to get other port");
try {tmp.close();} catch(Throwable e) {}
localPort++;