network

package
v1.4.18 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package network 网络代理

Package network 网络代理器

Package network tcp网络控制器

Package network tcp服务器

Package network websocket连接器

Package network websocket服务器

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Addr

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

Addr is an implementation of net.Addr for WebSocket.

func (*Addr) Network

func (addr *Addr) Network() string

Network returns the network type for a WebSocket, "websocket".

func (*Addr) String

func (addr *Addr) String() string

type Agent

type Agent interface {
	Run() error
	OnClose() error
}

Agent 代理

type Conn

type Conn interface {
	net.Conn
	Destroy()
	// contains filtered or unexported methods
}

Conn 网络代理接口

type ConnSet

type ConnSet map[net.Conn]struct{}

ConnSet tcp连接管理器

type TCPConn

type TCPConn struct {
	io.Reader //Read(p []byte) (n int, err error)
	io.Writer //Write(p []byte) (n int, err error)
	sync.Mutex
	// contains filtered or unexported fields
}

TCPConn tcp连接

func (*TCPConn) Close

func (tcpConn *TCPConn) Close() error

Close 关闭tcp连接

func (*TCPConn) Destroy

func (tcpConn *TCPConn) Destroy()

Destroy 断连

func (*TCPConn) LocalAddr

func (tcpConn *TCPConn) LocalAddr() net.Addr

LocalAddr 本地socket端口地址

func (*TCPConn) Read

func (tcpConn *TCPConn) Read(b []byte) (int, error)

Read read data

func (*TCPConn) RemoteAddr

func (tcpConn *TCPConn) RemoteAddr() net.Addr

RemoteAddr 远程socket端口地址

func (*TCPConn) SetDeadline

func (tcpConn *TCPConn) SetDeadline(t time.Time) error

SetDeadline A zero value for t means I/O operations will not time out.

func (*TCPConn) SetReadDeadline

func (tcpConn *TCPConn) SetReadDeadline(t time.Time) error

SetReadDeadline sets the deadline for future Read calls. A zero value for t means Read will not time out.

func (*TCPConn) SetWriteDeadline

func (tcpConn *TCPConn) SetWriteDeadline(t time.Time) error

SetWriteDeadline sets the deadline for future Write calls. Even if write times out, it may return n > 0, indicating that some of the data was successfully written. A zero value for t means Write will not time out.

func (*TCPConn) Write

func (tcpConn *TCPConn) Write(b []byte) (n int, err error)

Write b must not be modified by the others goroutines

type TCPServer

type TCPServer struct {
	Addr       string
	TLS        bool //是否支持tls
	CertFile   string
	KeyFile    string
	MaxConnNum int
	NewAgent   func(*TCPConn) Agent
	// contains filtered or unexported fields
}

TCPServer tcp服务器

func (*TCPServer) Close

func (server *TCPServer) Close()

Close 关闭TCP监听

func (*TCPServer) Start

func (server *TCPServer) Start()

Start 开始tcp监听

type WSConn

type WSConn struct {
	io.Reader //Read(p []byte) (n int, err error)
	io.Writer //Write(p []byte) (n int, err error)
	sync.Mutex
	// contains filtered or unexported fields
}

WSConn websocket连接

func (*WSConn) Close

func (wsConn *WSConn) Close() error

Close 关闭连接

func (*WSConn) Destroy

func (wsConn *WSConn) Destroy()

Destroy 注销连接

func (*WSConn) LocalAddr

func (wsConn *WSConn) LocalAddr() net.Addr

LocalAddr 获取本地socket地址

func (*WSConn) Read

func (wsConn *WSConn) Read(p []byte) (n int, err error)

Read goroutine not safe

func (*WSConn) RemoteAddr

func (wsConn *WSConn) RemoteAddr() net.Addr

RemoteAddr 获取远程socket地址

func (*WSConn) SetDeadline

func (wsConn *WSConn) SetDeadline(t time.Time) error

SetDeadline A zero value for t means I/O operations will not time out.

func (*WSConn) SetReadDeadline

func (wsConn *WSConn) SetReadDeadline(t time.Time) error

SetReadDeadline sets the deadline for future Read calls. A zero value for t means Read will not time out.

func (*WSConn) SetWriteDeadline

func (wsConn *WSConn) SetWriteDeadline(t time.Time) error

SetWriteDeadline sets the deadline for future Write calls. Even if write times out, it may return n > 0, indicating that some of the data was successfully written. A zero value for t means Write will not time out.

func (*WSConn) Write

func (wsConn *WSConn) Write(p []byte) (int, error)

Write Write

type WSHandler

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

WSHandler websocket 处理器

type WSServer

type WSServer struct {
	Addr        string
	TLS         bool //是否支持tls
	CertFile    string
	KeyFile     string
	MaxConnNum  int
	MaxMsgLen   uint32
	HTTPTimeout time.Duration
	NewAgent    func(*WSConn) Agent
	// contains filtered or unexported fields
}

WSServer websocket服务器

func (*WSServer) Close

func (server *WSServer) Close()

Close 停止监听websocket端口

func (*WSServer) Start

func (server *WSServer) Start()

Start 开启监听websocket端口

Jump to

Keyboard shortcuts

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