lmux

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChanListener

type ChanListener struct {
	// contains filtered or unexported fields
}

ChanListener .

func (*ChanListener) Accept

func (l *ChanListener) Accept() (net.Conn, error)

Accept accepts a connection.

func (*ChanListener) Addr

func (l *ChanListener) Addr() net.Addr

Addr returns the listener's network address.

func (*ChanListener) Close

func (l *ChanListener) Close() error

Close does nothing but implementing net.Conn.Close. User should call ListenerMux.Close to close it automatically.

func (*ChanListener) Decrease

func (l *ChanListener) Decrease()

Decrease decreases the online num if it's A.

type ListenerMux

type ListenerMux struct {
	// contains filtered or unexported fields
}

ListenerMux manages listeners and handle the connection dispatching logic.

func New

func New(maxOnlineA int) *ListenerMux

New returns a ListenerMux.

func (*ListenerMux) DecreaseOnlineA

func (lm *ListenerMux) DecreaseOnlineA()

DecreaseOnlineA decreases the online num of ChanListener A.

func (*ListenerMux) Mux

Mux creates and returns ChanListener A and B: If the online num of A is less than ListenerMux. maxOnlineA, the new connection will be dispatched to A; Else the new connection will be dispatched to B.

func (*ListenerMux) Start

func (lm *ListenerMux) Start()

Start starts to accept and dispatch the connections to ChanListener A or B.

func (*ListenerMux) Stop

func (lm *ListenerMux) Stop()

Stop stops all the listeners.

Jump to

Keyboard shortcuts

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