Allow server Start to accept a preconfigured listener.

* In testing scenarios where multiple packages each configure their
  own nats server, port collisions could happen. Without changing the
  behavior of gnatsd, this allows us to configure a listener
  externally with an available port, or generate a default listener
  in the main routine during normal server operation.
* Cowritten with Oleg.

@derekcollison @krobertson 
But aren't you sleeping the first time through before the Dial?


On Fri, Jun 6, 2014 at 3:48 PM, Alex Toombs <notifications@github.com>
wrote:

> In test/test.go:
>
> >  	end := time.Now().Add(10 * time.Second)
> >  	for time.Now().Before(end) {
> > -		conn, err := net.Dial("tcp", addr)
> > +		addr := s.Addr()
> > +		if addr == nil {
> > +			time.Sleep(10 * time.Millisecond)
>
> If the listener hasn't bound to the port yet, it hasn't returned and had a
> reference stored on s. That means we're calling a method on a nil
> pointer, (by doing addr.String()) and I observed panics in tests without
> this polling approach.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/apcera/gnatsd/pull/32/files#r13514216>.
>