network

package
v1.1.29 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Copyright 2014 mqant Author. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2014 mqant Author. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2014 mqant Author. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2014 mqant Author. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2014 mqant Author. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2014 mqant Author. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2014 mqant Author. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

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

type Conn

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

type ConnSet

type ConnSet map[net.Conn]struct{}

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
}

func (*TCPConn) Close

func (tcpConn *TCPConn) Close() error

func (*TCPConn) Destroy

func (tcpConn *TCPConn) Destroy()

func (*TCPConn) LocalAddr

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

func (*TCPConn) Read

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

func (*TCPConn) RemoteAddr

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

func (*TCPConn) SetDeadline

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

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)

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
}

func (*TCPServer) Close

func (server *TCPServer) Close()

func (*TCPServer) Start

func (server *TCPServer) Start()

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
}

func (*WSConn) Close

func (wsConn *WSConn) Close() error

func (*WSConn) Destroy

func (wsConn *WSConn) Destroy()

func (*WSConn) LocalAddr

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

func (*WSConn) Read

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

goroutine not safe

func (*WSConn) RemoteAddr

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

func (*WSConn) SetDeadline

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

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)

type WSHandler

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

func (*WSHandler) Echo

func (handler *WSHandler) Echo(conn *websocket.Conn)

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
}

func (*WSServer) Close

func (server *WSServer) Close()

func (*WSServer) Start

func (server *WSServer) Start()

Jump to

Keyboard shortcuts

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