Esempio n. 1
0
        static void Main(string[] args)
        {
            SocketClient client = new SocketClient();
            if (client.Connect("127.0.0.1", 5566))
            {
                client.BinaryInput += client_BinaryInput;
                client.StartRead();
                while (true)
                {
                    Console.ReadLine();


                    //for (int i = 0; i < 100000; i++)
                    //{
                        BufferFormat buffer = new BufferFormat(1000);
                        buffer.AddItem(1.ToString());
                        buffer.AddItem(new byte[64]);
                        byte[] data = buffer.Finish();
                        client.Send(data);
                        System.Threading.Thread.Sleep(1);
                  // }
                  



                }            

            }
        }
Esempio n. 2
0
        public void ConToServer()
        {
         
            Mainclient = new SocketClient();
            Mainclient.BinaryInput += new ClientBinaryInputHandler(DataIn);
            Mainclient.MessageInput += new ClientMessageInputHandler(Exption);

            if (Mainclient.Connect(Host, Port))
            {               
                Mainclient.StartRead();

                LogOut.LogIn("成功连接服务器", ActionType.ServerConn);

                string localip = ((IPEndPoint)(Mainclient.Sock.LocalEndPoint)).Address.ToString(); //获取本地局域网IP地址

                BufferFormatV2 tmp = new BufferFormatV2((int)PCMD.REGION);
                tmp.AddItem(Key);
                tmp.AddItem(localip);
                tmp.AddItem(Mac);
                Mainclient.Send(tmp.Finish());
              
            }
            else
            {             
                LogOut.LogIn("不能连接到服务器", ActionType.ServerNotConn);

                if (ServerDiscon != null)
                    ServerDiscon("不能连接到服务器");
            }

        }