snet

package
v0.0.0-...-cec807c Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2019 License: MIT Imports: 5 Imported by: 0

README

snet

这是一个简易的Tcp框架

snet.v4 适用于十分简陋的任务

数据包协议
---------------------------------------------------------------------------------
| 1 byte | 4 byte | 4 byte | n byte | 1 byte |
---------------------------------------------------------------------------------
| 起始符(!) | 数据长度(n) | 长度校验(CRC) | 数据 | 结束符(\n) |
---------------------------------------------------------------------------------

type server struct {
}

func main() {
	s := NewServer("localhost", "496", &server{})
	s.Serve()

}

func (this *server) OnConnect(conn *net.TCPConn) {

}

func (this *server) OnDisConnect(conn *net.TCPConn, reason string) {

}

func (this *server) OnRecvMessage(conn *net.TCPConn, msg []byte) {

}

func (this *server) OnSendMessage(conn *net.TCPConn) {

}



Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewServer

func NewServer(ip string, port string, s ISnet) *snet

Types

type ISnet

type ISnet interface {
	OnConnect(*net.TCPConn)
	OnDisConnect(*net.TCPConn, string)
	OnRecvMessage(*net.TCPConn, []byte)
	OnSendMessage(*net.TCPConn)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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