network

package
v0.0.0-...-9ff7eae Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dial

func Dial(protocol, addr string) error

func DialWithDialer

func DialWithDialer(dialer *net.Dialer, protocol, addr string) error

func StartHost

func StartHost(ctx context.Context, listenF int)

Types

type Client

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

func (*Client) Close

func (c *Client) Close()

OnClose implements TCPClient

func (*Client) Dia

func (c *Client) Dia(url string) error

func (*Client) OnClose

func (c *Client) OnClose() <-chan bool

OnClose implements TCPClient

func (*Client) OnReceive

func (c *Client) OnReceive() <-chan []byte

OnReceive implements TCPClient

func (*Client) Send

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

func (*Client) SetWriter

func (c *Client) SetWriter(writer io.Writer)

SetWriter implements TCPClient

type ConnID

type ConnID = uuid.UUID

type IBroadcaster

type IBroadcaster interface {
	Broadcast(message []byte) error
	OnBroadcaster()
	Send(addr string, message []byte) error
}

func NewUDPServer

func NewUDPServer(port, dialPort int) IBroadcaster

type TCPBasicServer

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

func (*TCPBasicServer) Broadcast

func (s *TCPBasicServer) Broadcast(msg []byte) error

Broadcast implements TCPServer

func (*TCPBasicServer) Listen

func (s *TCPBasicServer) Listen(port int) error

func (*TCPBasicServer) OnReceive

func (s *TCPBasicServer) OnReceive() <-chan []byte

OnReceive implements TCPServer

func (*TCPBasicServer) OnRegister

func (s *TCPBasicServer) OnRegister() <-chan TCPServerConn

OnRegister implements TCPServer

func (*TCPBasicServer) OnUnregister

func (s *TCPBasicServer) OnUnregister() <-chan TCPServerConn

OnUnregister implements TCPServer

func (*TCPBasicServer) Send

func (s *TCPBasicServer) Send(cid uuid.UUID, msg []byte) error

Send implements TCPServer

type TCPClient

type TCPClient interface {
	Close()
	OnClose() <-chan bool
	Dia(url string) error
	Send(msg []byte) error
	OnReceive() <-chan []byte
	SetWriter(writer io.Writer)
}

func NewTCPClient

func NewTCPClient() TCPClient

type TCPServer

type TCPServer interface {
	Listen(port int) error
	OnRegister() <-chan TCPServerConn
	OnUnregister() <-chan TCPServerConn
	OnReceive() <-chan []byte
	Send(cid ConnID, msg []byte) error
	Broadcast(msg []byte) error
}

func NewTCPServer

func NewTCPServer() TCPServer

type TCPServerConn

type TCPServerConn struct {
	ID ConnID
	// contains filtered or unexported fields
}

func (TCPServerConn) Send

func (c TCPServerConn) Send(message []byte) error

type UDPServer

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

func (*UDPServer) Broadcast

func (b *UDPServer) Broadcast(message []byte) error

func (*UDPServer) OnBroadcaster

func (b *UDPServer) OnBroadcaster()

func (*UDPServer) Send

func (b *UDPServer) Send(addr string, message []byte) error

Jump to

Keyboard shortcuts

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