stoppableListener

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2015 License: BSD-2-Clause, Apache-2.0 Imports: 3 Imported by: 0

README

stoppableListener

An example of a stoppable TCP listener in Go. This library wraps an existing TCP connection object. A goroutine calling Accept() is interrupted with StoppedError whenever the listener is stopped by a call to Stop(). Usage is demonstrated below, and in example/example.go.

	originalListener, err := net.Listen("tcp", ":8080")
	if err != nil {
		panic(err)
	}

	sl, err := stoppableListener.New(originalListener)
	if err != nil {
		panic(err)
	}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StoppedError = errors.New("Listener stopped")

Functions

This section is empty.

Types

type StoppableListener

type StoppableListener struct {
	*net.TCPListener //Wrapped listener
	// contains filtered or unexported fields
}

func New

func (*StoppableListener) Accept

func (sl *StoppableListener) Accept() (net.Conn, error)

func (*StoppableListener) Stop

func (sl *StoppableListener) Stop()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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