X.NET framework
Install
$ go get github.com/RealFax/XNET
This is a high-performance network framework, currently only supports tcp and FFAX protocol
Using goroutine and pointer passing, you can quickly generate a high-performance cloud stream application
How to work?
Think of XNET as a water pipe. You can set the size of the water pipe and the other end of the water pipe. This is XNET, and it integrates
chunk,
stream and other functions.
Quick start
package main
import (
"fmt"
"github.com/RealFax/FFAX/packet"
xNet "github.com/RealFax/XNET"
"net"
)
const (
MaxConnection int64 = 100
)
func tcpCallBack(conn net.Conn, service xNet.React) {
buf := make([]byte, 1024)
for {
n, err := conn.Read(buf)
if err != nil {
return
}
fmt.Println(string(buf[:n]))
}
}
func ffaxCallBack(conn net.Conn, secret []byte, service xNet.React) {
buf := make([]byte, 1024)
for {
n, err := conn.Read(buf)
if err != nil {
return
}
header, message, err := packet.DePacket(buf[:n], secret)
if err != nil {
return
}
fmt.Println(string(message))
for k, v := range header {
fmt.Printf("%s: %x\n", k, v)
}
}
}
func main() {
s, err := xNet.Listen("tcp", ":8080")
if err != nil {
return
}
s.SetMaxConnection(MaxConnection)
s.SetFunc(tcpCallBack)
s.Start()
}
⚠
Alert
This project has many experimental features, please use it with caution