func init() { // 根据协议类型创建acceptor p := tcp.ParseParam{} p.HeadSize = 23 p.BodySizeOffset = 21 p.BodySizeLen = 2 p.NotifyWithHead = true a = tcp.NewAcceptor(":8888", p) }
func client() *tcp.Connector { var id uint32 = 0 log.Println("client start") p := tcp.ParseParam{} p.HeadSize = 23 p.BodySizeOffset = 21 p.BodySizeLen = 2 p.NotifyWithHead = true c := tcp.NewConnector(id, "10.0.29.111:8888", p) c.HandleMessage(clientHandleMessage) c.HandleConnect(handleConnect) c.HandleDisconnect(handleDisconnect) c.Start() return c }