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.

49 lines
1.9KB

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