socket

package
v0.0.0-...-83af506 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

README

协议设计

request

|0000 0000|0000 0000|0000 0000|0000 0000|0000 0000|0000 0000|--------|0000 0000|0000 0000|------------| |--------length-----|----op---| 保留 |-------------------|key data|------value len----| value data |
key长度

response |0000 0000|0000 0000|0000 0000|0000 0000|0000 0000|0000 0000|--------|0000 0000|0000 0000|------------| |--------length-----|----op---| 保留 |----keylen -----|key data|------value len----| value data |
或者 err 长度 err

req op 和 http 保留一致

0 保留
1 Get 
2 PUT
3 Del

resp op

0 保留
1 成功
2 没有找到
3 服务器返回指定ip 

Documentation

Index

Constants

View Source
const (
	MIN_MSG_LEN    int = 4
	MAX_MSG_LEN    int = 4096
	MSG_HEAD_LEN   int = 2
	OP_LEN         int = 1 //操作位
	RETAIN_LEN         = 1 //保留长度
	KEY_HEAD_LEN   int = 2
	VALUE_HEAD_LEN int = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Socker

type Socker interface {
	ReadMsg(d *internal.Data) error
	WriteMsg(d *internal.Data) (n int, err error)
	RemoteIP() string
	Close()
}

func NewQuicStream

func NewQuicStream(stream quic.Stream) Socker

func NewTcpConn

func NewTcpConn(conn net.Conn) Socker

Jump to

Keyboard shortcuts

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