listenbuffer

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2016 License: Apache-2.0 Imports: 1 Imported by: 0

README

listenbuffer

listenbuffer uses the kernel's listening backlog functionality to queue connections, allowing applications to start listening immediately and handle connections later. This is signaled by closing the activation channel passed to the constructor.

The maximum amount of queued connections depends on the configuration of your kernel (typically called SOMAXXCON) and cannot be configured in Go with the net package. See src/net/sock_platform.go in the Go tree or consult your kernel's manual.

activator := make(chan struct{})
buffer, err := NewListenBuffer("tcp", "localhost:4000", activator)
if err != nil {
	panic(err)
}

// will block until activator has been closed or is sent an event
client, err := buffer.Accept()

Somewhere else in your application once it's been booted:

close(activator)

buffer.Accept() will return the first client in the kernel listening queue, or continue to block until a client connects or an error occurs.

Documentation

Overview

Package listenbuffer uses the kernel's listening backlog functionality to queue connections, allowing applications to start listening immediately and handle connections later. This is signaled by closing the activation channel passed to the constructor.

The maximum amount of queued connections depends on the configuration of your kernel (typically called SOMAXXCON) and cannot be configured in Go with the net package. See `src/net/sock_platform.go` in the Go tree or consult your kernel's manual.

activator := make(chan struct{})
buffer, err := NewListenBuffer("tcp", "localhost:4000", activator)
if err != nil {
	panic(err)
}

// will block until activator has been closed or is sent an event
client, err := buffer.Accept()

Somewhere else in your application once it's been booted:

close(activator)

`buffer.Accept()` will return the first client in the kernel listening queue, or continue to block until a client connects or an error occurs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewListenBuffer

func NewListenBuffer(proto, addr string, activate <-chan struct{}) (net.Listener, error)

NewListenBuffer returns a net.Listener listening on addr with the protocol passed. The channel passed is used to activate the listenbuffer when the caller is ready to accept connections.

Types

This section is empty.

Jump to

Keyboard shortcuts

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