1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/api/server/server_windows.go
David Calavera 0bfbc6e788 Extract sockets initialization to a package.
Because I just used it somewhere else and it would be nice if I didn't have to copy and paste the code.

Signed-off-by: David Calavera <david.calavera@gmail.com>
2015-05-20 16:48:39 -07:00

45 lines
782 B
Go

// +build windows
package server
import (
"errors"
"net"
"net/http"
"github.com/docker/docker/daemon"
)
// NewServer sets up the required Server and does protocol specific checking.
func (s *Server) newServer(proto, addr string) (Server, error) {
var (
err error
l net.Listener
)
switch proto {
case "tcp":
l, err = s.initTcpSocket(addr)
if err != nil {
return nil, err
}
default:
return nil, errors.New("Invalid protocol format. Windows only supports tcp.")
}
return &HttpServer{
&http.Server{
Addr: addr,
Handler: s.router,
},
l,
}, nil
}
func (s *Server) AcceptConnections(d *daemon.Daemon) {
s.daemon = d
// close the lock so the listeners start accepting connections
select {
case <-s.start:
default:
close(s.start)
}
}