Capstan is a Golang web framework that shares some similarities with others in its segment.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.9 KiB

// Windows-specific network support.
// This package defines certain calls that do not mesh well with Windows and
// require some significant modification(s) for non-POSIX platforms. In
// particular, we strip out graceful restart handling and initialization.
// Naturally, if anyone knows how to do something analogous in the Windows
// world, patches are welcome and these are the two entrypoints that lead to the
// public implementation. It may also be necessary to reimplement Relaunch().
package capstan
import (
// InitNetwork code. This sets up platform-specific signal handlers, sockets,
// and any metadata required to resume previous connections. It also returns
// either an error, used for initialization failures; an error channel, used for
// errors that might occur in a goroutine that has been called internally (if
// applicable; this may not be true for all platforms); and finally the close
// channel, which is used to indicate that the process is closing (usually
// triggered when the parent has successfully exec'd a child process and passed
// over copies of its file descriptors).
// For Windows, this does nothing.
func InitNetwork() (err error, errc chan error, close chan struct{}) {
fds = &fdmap{}
errc = make(chan error, 1)
close = make(chan struct{}, 1)
// Listen to the specified network address. Usually this will be a network value
// of "tcp" followed by a host/port construct. In the POSIX implementations of
// this function, it will handle the actual logic required to resume a socket
// connection following exec, and also record metadata related to the network
// connection for future resumption, if required.
// Under Windows, this is just a passthrough for net.Listen.
func Listen(network, addr string) (net.Listener, error) {
return net.Listen(network, addr)
func StopListening(listener net.Listener) error {
return listener.Close()