tcp

package
v2.0.0-...-143edb0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	ServerAddr string

	OnStateChange OnClientStateChange
	OnMsgRecv     OnClientMsgRecv

	Conn net.Conn

	State ClientState
	// contains filtered or unexported fields
}

func NewClient

func NewClient(serveraddr string) *Client

func (*Client) Send

func (c *Client) Send(msg []byte) error

func (*Client) SetOnMsgRecv

func (c *Client) SetOnMsgRecv(handler OnClientMsgRecv) *Client

func (*Client) SetOnStateChange

func (c *Client) SetOnStateChange(handler OnClientStateChange) *Client

func (*Client) Start

func (c *Client) Start() error

func (*Client) Stop

func (c *Client) Stop()

type ClientState

type ClientState int
const (
	ClientConnected ClientState = iota
	ClientDisconnected
)

type OnClientMsgRecv

type OnClientMsgRecv func(c *Client, msg []byte, err error)

type OnClientStateChange

type OnClientStateChange func(c *Client, newstate ClientState)

type Server

type Server struct {
	ServerAddr string

	OnClientStateChange OnClientStateChange
	OnClientMsgRecv     OnClientMsgRecv

	Listener net.Listener
	Conns    []net.Conn
}

func NewServer

func NewServer(addr string) *Server

func (*Server) SetOnMsgRecv

func (s *Server) SetOnMsgRecv(handler OnClientMsgRecv) *Server

func (*Server) SetOnPeerStateChange

func (s *Server) SetOnPeerStateChange(handler OnClientStateChange) *Server

func (*Server) Start

func (s *Server) Start() error

func (*Server) Stop

func (s *Server) Stop()

Jump to

Keyboard shortcuts

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