x-mod / tcpserver

a very simple & convenient tcp server framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tcpserver

Installation

$: go get github.com/x-mod/tcpserver

Quick Start

import (
    "net"
    "log"
	"context"
	"github.com/x-mod/tcpserver"
)

func EchoHandler(ctx context.Context, con net.Conn) error {
    //TODO LOGIC
    return nil
}

func main() {
	srv := tcpserver.New(
		tcpserver.Address(":8080"),
		//tcpserver.TLSConfig(tlsconfig),
		tcpserver.TCPHandler(EchoHandler),
	)
	if err := srv.Serve(context.TODO()); err != nil {
		log.Println("tcpserver failed:", err)
	}
}

More Details, Pls check the example.

About

a very simple & convenient tcp server framework

License:MIT License


Languages

Language:Go 100.0%