// Use this for initialization
    void Start()
    {
        //registe bytes msg
        MsgManager.Instance.RegisterMsg(110, OnByteMsg);
        //you can registe many msg here
        //....

        //registe protobuf msg
        MsgManager.Instance.RegisterMsg(typeof(TestProtobufStruct).FullName, OnProtobufMsg);
        //....

        //connect(prefer host names)
        ClientTcp socket        = new ClientTcp();
        bool      tempIsConnect = socket.Connect("www.google.com", 111);

        Debug.Log("是否连接成功: " + tempIsConnect);

        // send byte msg
        MsgByte tempMsg1 = new MsgByte(110); //110 is proto id

        tempMsg1.Write <int>(100);           //write msg's body
        tempMsg1.Write("hello");             //write msg's body
        tempMsg1.Flush();                    //send

        //send protobuf msg
        TestProtobufStruct testProtobufStruct = new TestProtobufStruct();

        testProtobufStruct.x = 100;
        testProtobufStruct.y = "hello";
        MsgProtobuf tempMsg2 = new MsgProtobuf();

        tempMsg2.Write(testProtobufStruct);
        tempMsg2.Flush();//send
    }