listener

package
v0.23.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2024 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Overview

Package listener provides generic functions which extend the capabilities of the http package. This is a fork of github.com/m-lab/go which is specially tailored for the needs of ndt7. I believe we will want to enhance the code at github.com/m-lab/go and make this code unnecessary.

The code here eliminates an annoying race condition in net/http that prevents you from knowing when it is safe to connect to the server socket. For the functions in this package, the listening socket is fully estabished when the function returns, and it is safe to run an HTTP GET immediately.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenAndServeAsync

func ListenAndServeAsync(server *http.Server) error

ListenAndServeAsync starts an http server. The server will run until Shutdown() or Close() is called, but this function will return once the listening socket is established. This means that when this function returns, the server is immediately available for an http GET to be run against it.

Returns a non-nil error if the listening socket can't be established. Logs a fatal error if the server dies for a reason besides ErrServerClosed. If the server.Addr is set to :0, then after this function returns server.Addr will contain the address and port which this server is listening on.

func ListenAndServeTLSAsync

func ListenAndServeTLSAsync(server *http.Server, certFile, keyFile string) error

ListenAndServeTLSAsync starts an https server. The server will run until Shutdown() or Close() is called, but this function will return once the listening socket is established. This means that when this function returns, the server is immediately available for an https GET to be run against it.

Returns a non-nil error if the listening socket can't be established. Logs a fatal error if the server dies for a reason besides ErrServerClosed.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL