tcp

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2019 License: MIT Imports: 9 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 {
	Addr    string
	TLSConf *tls.Config
}

Client is a TCP client for golang client

func NewClient

func NewClient(addr string) *Client

NewClient returns new TCP client with address

func (*Client) DecodeFromProto

func (cl *Client) DecodeFromProto(data []byte, dst interface{}) error

DecodeFromProto decodes proto msg from bytes

func (*Client) DecodeRoutes

func (cl *Client) DecodeRoutes(data []byte) ([]drpcnet.Route, []drpcnet.Route, error)

DecodeRoutes decodes response to _getRoutes request

func (*Client) Dial

func (cl *Client) Dial(secureType int) (drpcnet.Conn, error)

Dial creates connect to address 0 - TLS secure with validate certificate. We use user's cl.TLSConf or default if it will nil 1 - Secure connection but without validate certificate 2 - Insecure without TLS

func (*Client) EncodeToProto

func (cl *Client) EncodeToProto(msg interface{}) ([]byte, error)

EncodeToProto encodes proto msg to bytes

type Conn

type Conn struct {
	net.Conn
	// contains filtered or unexported fields
}

Conn is connection to tcp server

func (*Conn) LocalAddr

func (c *Conn) LocalAddr() drpcnet.Addr

LocalAddr returns the local network address

func (*Conn) ReadMsg

func (c *Conn) ReadMsg() ([]byte, error)

ReadMsg reads message from connection

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() drpcnet.Addr

RemoteAddr returns the remote network address

func (*Conn) WriteMsg

func (c *Conn) WriteMsg(data []byte) error

WriteMsg writes message to connection

Jump to

Keyboard shortcuts

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