|  | @@ -3,23 +3,23 @@ package ws
 | 
											
												
													
														|  |  import (
 |  |  import (
 | 
											
												
													
														|  |  	"errors"
 |  |  	"errors"
 | 
											
												
													
														|  |  	"net"
 |  |  	"net"
 | 
											
												
													
														|  | -	"time"
 |  | 
 | 
											
												
													
														|  |  )
 |  |  )
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  type StoppableListener struct {
 |  |  type StoppableListener struct {
 | 
											
												
													
														|  | -	*net.TCPListener          //Wrapped listener
 |  | 
 | 
											
												
													
														|  | -	stop             chan int //Channel used only to indicate listener should shutdown
 |  | 
 | 
											
												
													
														|  | 
 |  | +	net.Listener          //Wrapped listener
 | 
											
												
													
														|  | 
 |  | +	stop         chan int //Channel used only to indicate listener should shutdown
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  func NewStoppableListener(l net.Listener) (*StoppableListener, error) {
 |  |  func NewStoppableListener(l net.Listener) (*StoppableListener, error) {
 | 
											
												
													
														|  | -	tcpL, ok := l.(*net.TCPListener)
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -	if !ok {
 |  | 
 | 
											
												
													
														|  | -		return nil, errors.New("Cannot wrap listener")
 |  | 
 | 
											
												
													
														|  | -	}
 |  | 
 | 
											
												
													
														|  | 
 |  | +	/*
 | 
											
												
													
														|  | 
 |  | +		tcpL, ok := l.(*net.TCPListener)
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +		if !ok {
 | 
											
												
													
														|  | 
 |  | +			return nil, errors.New("Cannot wrap listener")
 | 
											
												
													
														|  | 
 |  | +		}
 | 
											
												
													
														|  | 
 |  | +	*/
 | 
											
												
													
														|  |  	retval := &StoppableListener{}
 |  |  	retval := &StoppableListener{}
 | 
											
												
													
														|  | -	retval.TCPListener = tcpL
 |  | 
 | 
											
												
													
														|  | 
 |  | +	retval.Listener = l
 | 
											
												
													
														|  |  	retval.stop = make(chan int)
 |  |  	retval.stop = make(chan int)
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  	return retval, nil
 |  |  	return retval, nil
 | 
											
										
											
												
													
														|  | @@ -30,10 +30,7 @@ var StoppedError = errors.New("Listener stopped")
 | 
											
												
													
														|  |  func (sl *StoppableListener) Accept() (net.Conn, error) {
 |  |  func (sl *StoppableListener) Accept() (net.Conn, error) {
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  	for {
 |  |  	for {
 | 
											
												
													
														|  | -		//Wait up to one second for a new connection
 |  | 
 | 
											
												
													
														|  | -		sl.SetDeadline(time.Now().Add(time.Second))
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -		newConn, err := sl.TCPListener.Accept()
 |  | 
 | 
											
												
													
														|  | 
 |  | +		newConn, err := sl.Listener.Accept()
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  		//Check for the channel being closed
 |  |  		//Check for the channel being closed
 | 
											
												
													
														|  |  		select {
 |  |  		select {
 |