🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
[TOC] > [参考](https://github.com/xfxdev/xtcp) ## 概述 具有正常关闭,自定义协议的TCP Server框架。 ## 使用 Create server: ``` // 1. create protocol and handler. // ... // 2. create opts. opts := xtcp.NewOpts(handler, protocol) // 3. create server. server := xtcp.NewServer(opts) // 4. start. go server.ListenAndServe("addr") ``` Create client: ``` // 1. create protocol and handler. // ... // 2. create opts. opts := xtcp.NewOpts(handler, protocol) // 3. create client. client := NewConn(opts) // 4. start go client.DialAndServe("addr") ```